diff --git a/src/runner.py b/src/runner.py index 46819ed..344bd10 100644 --- a/src/runner.py +++ b/src/runner.py @@ -8,7 +8,7 @@ from loguru import logger from src.dirmanager import DirManager -class SubTest(TypedDict): +class ConditionalTest(TypedDict): condition: Callable[[dict[str, str]], bool] test_file: str @@ -20,7 +20,7 @@ class Runner: main_test_name: Optional[str] = None main_cleanup_name: Optional[str] = None dependencies: list[type["Runner"]] = [] - sub_tests: list[SubTest] = [] + conditional_tests: list[ConditionalTest] = [] prevent_skip = False def __init__(self, dotenv_path: Path, output_dir: Path, session_id: str): @@ -69,12 +69,12 @@ class Runner: ) # run sub tests if conditions are met - for sub_test in self.sub_tests: - condition_function = sub_test["condition"] - sub_test_name = sub_test["test_file"] - identifier_string = self.combine_names(self.name, sub_test_name) + for cond_test in self.conditional_tests: + condition_function = cond_test["condition"] + cond_test_name = cond_test["test_file"] + identifier_string = self.combine_names(self.name, cond_test_name) if condition_function(self.config): - test_path = self.root_dir / self.test_dir_name / sub_test_name + test_path = self.root_dir / self.test_dir_name / cond_test_name self._run_or_skip_test(identifier_string=identifier_string, test_path=test_path) else: self._create_result_file(result=-1, identifier_string=identifier_string) @@ -100,12 +100,12 @@ class Runner: self._create_result_file(result=result, identifier_string=identifier_string) def _is_test_passed(self, identifier_string: str, remove_existing: bool = False) -> bool: - """returns True if the selected test (matching test_name + sub_test_name) already passed + """returns True if the selected test matching identifier_string already passed This is determined by the presence of a specific output file in the RESULTS folder that matches identifier_string - remove_existing: If True, result files matching test_name + sub_test_name with a status + remove_existing: If True, result files matching identifier_string with a status other than 'passed' will be deleted""" already_passed = False diff --git a/src/tests_authentik/runner_authentik.py b/src/tests_authentik/runner_authentik.py index 59c486e..9b7218f 100644 --- a/src/tests_authentik/runner_authentik.py +++ b/src/tests_authentik/runner_authentik.py @@ -1,4 +1,4 @@ -from src.runner import Runner, SubTest +from src.runner import Runner def condition_always_true(dotenv_config: dict[str, str]) -> bool: diff --git a/src/tests_demo/runner_demo.py b/src/tests_demo/runner_demo.py index 8f36e9c..310cf93 100644 --- a/src/tests_demo/runner_demo.py +++ b/src/tests_demo/runner_demo.py @@ -1,6 +1,6 @@ from typing import Optional -from src.runner import Runner, SubTest +from src.runner import ConditionalTest, Runner from src.tests_authentik.runner_authentik import RunnerAuthentik @@ -24,6 +24,6 @@ class RunnerDemo(Runner): dependencies: list[type["Runner"]] = [RunnerAuthentik] # this list can hold many more tests from RunnerDemo that run conditional. The condition - # and the test file can be defined by creating a SubTest instance: - # SubTest(condition: Callable, test_file: str) - sub_tests: list[SubTest] = [] + # and the test file can be defined by creating a ConditionalTest instance: + # ConditionalTest(condition: Callable, test_file: str) + conditional_tests: list[ConditionalTest] = [] diff --git a/src/tests_nextcloud/runner_nextcloud.py b/src/tests_nextcloud/runner_nextcloud.py index e5442f6..36c7bd9 100644 --- a/src/tests_nextcloud/runner_nextcloud.py +++ b/src/tests_nextcloud/runner_nextcloud.py @@ -1,4 +1,4 @@ -from src.runner import Runner, SubTest +from src.runner import ConditionalTest, Runner from src.tests_authentik.runner_authentik import RunnerAuthentik @@ -13,4 +13,6 @@ class RunnerNextcloud(Runner): main_test_name = "tests_nextcloud.py" # main_cleanup_name = "cleanup_nextcloud.py" dependencies = [RunnerAuthentik] - sub_tests: list[SubTest] = [SubTest(condition=fake_condition, test_file="tests_nextcloud_onlyoffice.py")] + conditional_tests: list[ConditionalTest] = [ + ConditionalTest(condition=fake_condition, test_file="tests_nextcloud_onlyoffice.py") + ] diff --git a/src/tests_wordpress/runner_wordpress.py b/src/tests_wordpress/runner_wordpress.py index 1f9f4cd..186a554 100644 --- a/src/tests_wordpress/runner_wordpress.py +++ b/src/tests_wordpress/runner_wordpress.py @@ -1,4 +1,4 @@ -from src.runner import Runner, SubTest +from src.runner import ConditionalTest, Runner from src.tests_authentik.runner_authentik import RunnerAuthentik @@ -23,7 +23,7 @@ class RunnerWordpress(Runner): main_setup_name = "setup_wordpress.py" main_test_name = "test_wordpress.py" dependencies: list[type[Runner]] = [RunnerAuthentik] - sub_tests = [ - # SubTest(condition=condition_has_locale, test_file="test_wordpress_localization.py"), + conditional_tests = [ + # ConditionalTest(condition=condition_has_locale, test_file="test_wordpress_localization.py"), ] prevent_skip = True