implement env manager (#6)

* add EnvManager class

* holds all functions that are env file related

* integrates runner dependency resolution

* add integration and unit tests for EnvManager

Reviewed-on: local-it-infrastructure/e2e_tests#6
Co-authored-by: Daniel <d.brummerloh@gmail.com>
Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
Daniel 2023-12-04 17:09:01 +01:00 committed by dan
parent d3dc0f942a
commit 3fa10aaa69
18 changed files with 264 additions and 198 deletions

65
src/dir_manager.py Normal file
View file

@ -0,0 +1,65 @@
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) -> 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"