[WIP] Add new automated test framework (#1)
Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
859bd57006
commit
97ed87c79f
31 changed files with 769 additions and 6 deletions
53
src/dirmanager.py
Normal file
53
src/dirmanager.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
from pathlib import Path
|
||||
|
||||
|
||||
class DirManager:
|
||||
"""Manages directories for the tests and should be used to create and find
|
||||
and use the correct directories.
|
||||
|
||||
The structures is as follows:
|
||||
tests dir/
|
||||
session_dir-1/
|
||||
records
|
||||
states
|
||||
results
|
||||
session_dir-2/
|
||||
records
|
||||
...
|
||||
"""
|
||||
|
||||
def __init__(self, tests_dir: Path, session_id: str):
|
||||
# root test dir
|
||||
self.tests_dir = tests_dir
|
||||
self.session_id = session_id
|
||||
|
||||
self.dirs = self._get_all_dirs()
|
||||
|
||||
def create_all_dirs(self):
|
||||
self.create_dirs(self.tests_dir, exist_ok=True)
|
||||
self.create_dirs(self.dirs)
|
||||
|
||||
def _get_all_dirs(self):
|
||||
dirs = {}
|
||||
dirs["session"] = self.tests_dir / f"test-{self.session_id}"
|
||||
dirs.update(self._get_subdirs(session_dir=dirs["session"]))
|
||||
return dirs
|
||||
|
||||
def _get_subdirs(self, session_dir: Path):
|
||||
return {
|
||||
"records": session_dir / Path("records"),
|
||||
"states": session_dir / Path("states"),
|
||||
"results": session_dir / Path("results"),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
def create_dirs(dirs: Path | list[Path] | dict[str, Path], exist_ok=False):
|
||||
match dirs:
|
||||
case Path():
|
||||
dirs.mkdir(exist_ok=exist_ok)
|
||||
case list():
|
||||
for d in dirs:
|
||||
d.mkdir(exist_ok=exist_ok)
|
||||
case dict():
|
||||
for d in dirs.values():
|
||||
d.mkdir(exist_ok=exist_ok)
|
||||
Loading…
Add table
Add a link
Reference in a new issue