Before, a test had only access to it's own env file / configuration (wordpress could see wordpress env file). Now, all env files are available. Wordpress test can also read authentik env file, for example to get the authentik domain. Reviewed-on: local-it-infrastructure/e2e_tests#4 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(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)
|