71 lines
1.7 KiB
Python
71 lines
1.7 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, recipes_dir: Path | str = ""):
|
|
if isinstance(output_dir, str):
|
|
output_dir = Path(output_dir)
|
|
self.output_dir = output_dir.resolve()
|
|
self.session_id = session_id
|
|
if isinstance(recipes_dir, str):
|
|
recipes_dir = Path(recipes_dir)
|
|
self.recipes_dir = recipes_dir
|
|
|
|
def create_all_dirs(self) -> None:
|
|
dirs: list[Path] = [
|
|
self.OUTPUT_DIR,
|
|
self.SESSION,
|
|
self.RECORDS,
|
|
self.HTML,
|
|
self.STATES,
|
|
self.ENV_FILES,
|
|
self.RESULTS,
|
|
]
|
|
for d in dirs:
|
|
d.mkdir(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"
|
|
|
|
@property
|
|
def RECIPES(self):
|
|
return self.recipes_dir
|