* refactoring and rework: runner now has setups / tests / cleanups as lists * add nextcloud runner * add email testing prototype with imap fixture * add dependency resolution (sort env files in input so that test order is correct) Reviewed-on: local-it-infrastructure/e2e_tests#5 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
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
|
|
results
|
|
states
|
|
session_dir-2/
|
|
records
|
|
...
|
|
"""
|
|
|
|
def __init__(self, output_dir: Path | str, session_id: str):
|
|
# root test dir
|
|
if isinstance(output_dir, str):
|
|
output_dir = Path(output_dir)
|
|
self._output_dir = output_dir.resolve()
|
|
self.session_id = session_id
|
|
|
|
def create_all_dirs(self):
|
|
self.create_dirs(self._output_dir, exist_ok=True)
|
|
self.create_dirs(
|
|
[self.SESSION, self.RECORDS, self.HTML, self.STATES, self.ENV_FILES, self.RESULTS], exist_ok=True
|
|
)
|
|
|
|
@property
|
|
def OUTPUT_DIR(self):
|
|
return self._output_dir
|
|
|
|
@property
|
|
def SESSION(self):
|
|
return self.OUTPUT_DIR / f"test-{self.session_id}"
|
|
|
|
@property
|
|
def RECORDS(self):
|
|
return self.SESSION / "records"
|
|
|
|
@property
|
|
def HTML(self):
|
|
return self.RECORDS / "html"
|
|
|
|
@property
|
|
def STATES(self):
|
|
return self.SESSION / "states"
|
|
|
|
@property
|
|
def ENV_FILES(self):
|
|
return self.STATES / "env_files"
|
|
|
|
@property
|
|
def RESULTS(self):
|
|
return self.SESSION / "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)
|