From f865cda6b4c0cc3d4db919345faf18735ce24446 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 22 Nov 2023 14:33:00 +0100 Subject: [PATCH] restructure Wrapper, update TestRunner protocol --- src/main.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main.py b/src/main.py index cfda325..c9e220c 100644 --- a/src/main.py +++ b/src/main.py @@ -17,7 +17,7 @@ ENV_FILES = [ class TestRunner(Protocol): - def __init__(self, dotenv_path: Path): + def __init__(self, dotenv_path: Path, tests_dir: Path, session_id: str): ... def run_tests(self): @@ -32,17 +32,14 @@ RUNNER_DICT: dict[str, type[TestRunner]] = { class Wrapper: - def __init__(self, env_files: list[Path]): + def __init__(self, env_files: list[Path], session_id: str): self.env_files = env_files self.check_env_files(self.env_files) + self.session_id = session_id - session_id = self.get_session_id() - self.setup_test(session_id) - self.run_test() - - def setup_test(self, session_id: str): - self.dir_manager = DirManager(tests_dir=TESTS_DIR, session_id=session_id) + def setup_test(self): + self.dir_manager = DirManager(tests_dir=TESTS_DIR, session_id=self.session_id) self.dir_manager.create_all_dirs() def run_test(self): @@ -55,6 +52,7 @@ class Wrapper: config: dict[str, str] = dotenv_values(env_file) RunnerClass = RUNNER_DICT[config["TYPE"]] runners.append(RunnerClass(env_file)) + RunnerClass(dotenv_path=env_file, tests_dir=TESTS_DIR, session_id=) return runners def run_tests(self, runners: list[TestRunner]): @@ -74,4 +72,8 @@ class Wrapper: if __name__ == "__main__": - t = Wrapper(ENV_FILES) + session_id = Wrapper.get_session_id() + wrapper = Wrapper(ENV_FILES) + wrapper.setup_test() + wrapper.run_test() +