refactor for independent test dirs (#7)
* make it so that the actual tests can be moved anywhere, for example in abra recipe repos -> major refactoring with pytest test discovery magic * create RUNNER_DICT dynamically with importlib -> none of the tests are hardcoded, more tests can be added by placing a folder * autoload fixtures with pytest plugins * add URL fixture to navigate on web pages. Includes url parser based on python urllib to generate correct links * fix nextcloud setups and tests * add email groundwork with imbox Reviewed-on: local-it-infrastructure/e2e_tests#7 Co-authored-by: Daniel <d.brummerloh@gmail.com> Co-committed-by: Daniel <d.brummerloh@gmail.com>
This commit is contained in:
parent
3fa10aaa69
commit
f9c21c6e6b
45 changed files with 373 additions and 228 deletions
71
abratest/dir_manager.py
Normal file
71
abratest/dir_manager.py
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue