From 813804e33af0a1b9a43ed2b04b30f5071ad433b6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:09:08 +0100 Subject: [PATCH 01/16] pass coordinator to runner -> much more information available --- abratest/coordinator.py | 4 ++-- abratest/runner.py | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/abratest/coordinator.py b/abratest/coordinator.py index 11e4b7f..318586f 100644 --- a/abratest/coordinator.py +++ b/abratest/coordinator.py @@ -42,12 +42,12 @@ class Coordinator: def _load_runners(self, env_files: list[EnvFile]) -> list[Runner]: """Creates an instance of the correct Runner class for each given env file""" runners: list[Runner] = [] - for env_file in env_files: + for index, env_file in enumerate(env_files): RunnerClass = self.RUNNER_DICT[env_file.config["TYPE"]] dependency_classes: list[type[Runner]] = [] for dependency in RunnerClass.dependencies: dependency_classes.append(self.RUNNER_DICT[dependency]) - runner_instance = RunnerClass(dotenv_path=env_file.env_path, DIR=self.DIR) + runner_instance = RunnerClass(coordinator=self, runner_index=index) runner_instance._dependency_runners = dependency_classes runners.append(runner_instance) return runners diff --git a/abratest/runner.py b/abratest/runner.py index 8ea95a4..e572c7a 100644 --- a/abratest/runner.py +++ b/abratest/runner.py @@ -1,12 +1,13 @@ from dataclasses import dataclass from pathlib import Path -from typing import Callable +from typing import TYPE_CHECKING, Callable import pytest -from dotenv import dotenv_values from loguru import logger -from abratest.dir_manager import DirManager +if TYPE_CHECKING: + from abratest.coordinator import Coordinator + from abratest.env_manager import EnvFile @dataclass @@ -25,10 +26,16 @@ class Runner: dependencies: list[str] = [] _dependency_runners: list[type["Runner"]] = [] - def __init__(self, dotenv_path: Path, DIR: DirManager): - self.dotenv_path = dotenv_path - self.config: dict[str, str] = dotenv_values(dotenv_path) # type: ignore - self.DIR = DIR + def __init__(self, coordinator: "Coordinator", runner_index: int): + self.coordinator = coordinator # needed? + self.runner_index = runner_index # needed? + + self.DIR = coordinator.DIR + self.ENV = coordinator.ENV + + self.env_file: EnvFile = self.ENV.env_files[self.runner_index] + self.dotenv_path = self.env_file.env_path + self.config = self.env_file.config logger.info(f"creating instance of {self.__class__.__name__}") assert self.test_dir_name -- 2.47.2 From ce5530273e1eb2e39916f0e0b5f8a73a1ef5f965 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:10:23 +0100 Subject: [PATCH 02/16] remove unused root_dir --- abratest/runner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/abratest/runner.py b/abratest/runner.py index e572c7a..85e2ae9 100644 --- a/abratest/runner.py +++ b/abratest/runner.py @@ -39,7 +39,6 @@ class Runner: logger.info(f"creating instance of {self.__class__.__name__}") assert self.test_dir_name - self.root_dir = Path(__file__).parent def run_setups(self): """runs the setup scripts if available""" -- 2.47.2 From 65328d98169ec4846e0f9993751a3ba63c92f954 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:12:04 +0100 Subject: [PATCH 03/16] remove test --- abratest/runner.py | 1 - 1 file changed, 1 deletion(-) diff --git a/abratest/runner.py b/abratest/runner.py index 85e2ae9..79545b6 100644 --- a/abratest/runner.py +++ b/abratest/runner.py @@ -38,7 +38,6 @@ class Runner: self.config = self.env_file.config logger.info(f"creating instance of {self.__class__.__name__}") - assert self.test_dir_name def run_setups(self): """runs the setup scripts if available""" -- 2.47.2 From e415b8a16a4ff5fad232a3b25c0e242f1671ea85 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:19:44 +0100 Subject: [PATCH 04/16] fully remove test_dir_name --- abratest/runner.py | 6 ++++-- recipes/authentik/tests_authentik/runner_authentik.py | 1 - recipes/demo/tests_demo/runner_demo.py | 1 - recipes/nextcloud/tests_nextcloud/runner_nextcloud.py | 1 - recipes/wordpress/tests_wordpress/runner_wordpress.py | 1 - 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/abratest/runner.py b/abratest/runner.py index 79545b6..adc6ba0 100644 --- a/abratest/runner.py +++ b/abratest/runner.py @@ -19,7 +19,6 @@ class Test: class Runner: name: str = "" - test_dir_name: str = "" setups: list[Test] = [] tests: list[Test] = [] cleanups: list[Test] = [] @@ -69,7 +68,10 @@ class Runner: # condition_met: true / false identifier_string = self.combine_names(self.name, test.test_file) - full_test_path = self.DIR.RECIPES / self.name / self.test_dir_name / test.test_file + + results = list(self.DIR.RECIPES.rglob(test.test_file)) + assert len(results) == 1, f"{test.test_file} should exist exactly 1 time, but found {len(results)} times" + full_test_path = results[0] # check if test aleady passed if self._is_test_passed(identifier_string, remove_existing=True): diff --git a/recipes/authentik/tests_authentik/runner_authentik.py b/recipes/authentik/tests_authentik/runner_authentik.py index a3bba32..41f51a6 100644 --- a/recipes/authentik/tests_authentik/runner_authentik.py +++ b/recipes/authentik/tests_authentik/runner_authentik.py @@ -11,6 +11,5 @@ def condition_always_false(dotenv_config: dict[str, str]) -> bool: class RunnerAuthentik(Runner): name = "authentik" - test_dir_name = "tests_authentik" setups = [Test(test_file="setup_authentik.py")] # tests = [Test(test_file="test_authentik_dummy.py")] diff --git a/recipes/demo/tests_demo/runner_demo.py b/recipes/demo/tests_demo/runner_demo.py index ab2618c..d84ac2f 100644 --- a/recipes/demo/tests_demo/runner_demo.py +++ b/recipes/demo/tests_demo/runner_demo.py @@ -5,7 +5,6 @@ class RunnerDemo(Runner): """Every env file has a corresponding runner class""" name: str = "demo" # name of the test, used for logging / output naming - test_dir_name: str = "tests_demo" # dir name holding all tests related to RunnerDemo # this indicates that tests from RunnerDemo depend on the setup from RunnerAuthentik. # RunnerDemo will only execute, when setup_authentik.py has finished successfully. diff --git a/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py b/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py index 8ea7063..aa4e89a 100644 --- a/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py +++ b/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py @@ -7,7 +7,6 @@ def condition_always_false(dotenv_config: dict[str, str]) -> bool: class RunnerNextcloud(Runner): name: str = "nextcloud" - test_dir_name: str = "tests_nextcloud" dependencies = ["authentik"] setups = [Test(test_file="setup_nextcloud.py", prevent_skip=False)] tests = [ diff --git a/recipes/wordpress/tests_wordpress/runner_wordpress.py b/recipes/wordpress/tests_wordpress/runner_wordpress.py index 7167ce8..9813142 100644 --- a/recipes/wordpress/tests_wordpress/runner_wordpress.py +++ b/recipes/wordpress/tests_wordpress/runner_wordpress.py @@ -18,7 +18,6 @@ def condition_has_locale(dotenv_config: dict[str, str]) -> bool: class RunnerWordpress(Runner): name = "wordpress" - test_dir_name = "tests_wordpress" dependencies = ["authentik"] setups = [Test(test_file="setup_wordpress.py")] tests = [ -- 2.47.2 From a6c7a18e7b42daf102dbf952e7627deea6fbc112 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:24:37 +0100 Subject: [PATCH 05/16] rename runner.name to runner.env_type --- abratest/coordinator.py | 2 +- abratest/env_manager.py | 2 +- abratest/runner.py | 8 ++++---- recipes/authentik/tests_authentik/runner_authentik.py | 2 +- recipes/demo/tests_demo/runner_demo.py | 2 +- recipes/nextcloud/tests_nextcloud/runner_nextcloud.py | 2 +- recipes/wordpress/tests_wordpress/runner_wordpress.py | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/abratest/coordinator.py b/abratest/coordinator.py index 318586f..82fda18 100644 --- a/abratest/coordinator.py +++ b/abratest/coordinator.py @@ -104,5 +104,5 @@ class Coordinator: assert len(runner_class_names) == 1 runner_class_name = runner_class_names[0] RunnerClass: type[Runner] = getattr(module, runner_class_name) - RUNNER_DICT[RunnerClass.name] = RunnerClass + RUNNER_DICT[RunnerClass.env_type] = RunnerClass return RUNNER_DICT diff --git a/abratest/env_manager.py b/abratest/env_manager.py index 18086e2..00d412e 100644 --- a/abratest/env_manager.py +++ b/abratest/env_manager.py @@ -46,7 +46,7 @@ class EnvManager: for env_file in env_files: child_runner_class = RUNNER_DICT[env_file.env_type] for dependency in child_runner_class.dependencies: - dependency_rule = DependencyRule(child=child_runner_class.name, dependency=dependency) + dependency_rule = DependencyRule(child=child_runner_class.env_type, dependency=dependency) dependency_rules.append(dependency_rule) return dependency_rules diff --git a/abratest/runner.py b/abratest/runner.py index adc6ba0..f69186b 100644 --- a/abratest/runner.py +++ b/abratest/runner.py @@ -18,7 +18,7 @@ class Test: class Runner: - name: str = "" + env_type: str = "" setups: list[Test] = [] tests: list[Test] = [] cleanups: list[Test] = [] @@ -54,7 +54,7 @@ class Runner: """runs the main test script and if available and sub test scripts if their running condition is met""" # check if required dependencies have passed if not self._dependencies_passed(): - logger.warning(f"skipping run_tests() of {self.name}, because some dependencies have not passed") + logger.warning(f"skipping run_tests() of {self.env_type}, because some dependencies have not passed") return for test in test_list: @@ -67,7 +67,7 @@ class Runner: # condition_available: true / pass # condition_met: true / false - identifier_string = self.combine_names(self.name, test.test_file) + identifier_string = self.combine_names(self.env_type, test.test_file) results = list(self.DIR.RECIPES.rglob(test.test_file)) assert len(results) == 1, f"{test.test_file} should exist exactly 1 time, but found {len(results)} times" @@ -177,7 +177,7 @@ class Runner: results = [] for dependency_runner in self._dependency_runners: for setup_name in dependency_runner.setups: - dependencie_identifier = self.combine_names(dependency_runner.name, setup_name.test_file) + dependencie_identifier = self.combine_names(dependency_runner.env_type, setup_name.test_file) results.append(any(dependencie_identifier in f for f in passed_tests)) return all(results) diff --git a/recipes/authentik/tests_authentik/runner_authentik.py b/recipes/authentik/tests_authentik/runner_authentik.py index 41f51a6..b83da2f 100644 --- a/recipes/authentik/tests_authentik/runner_authentik.py +++ b/recipes/authentik/tests_authentik/runner_authentik.py @@ -10,6 +10,6 @@ def condition_always_false(dotenv_config: dict[str, str]) -> bool: class RunnerAuthentik(Runner): - name = "authentik" + env_type = "authentik" setups = [Test(test_file="setup_authentik.py")] # tests = [Test(test_file="test_authentik_dummy.py")] diff --git a/recipes/demo/tests_demo/runner_demo.py b/recipes/demo/tests_demo/runner_demo.py index d84ac2f..2b9aa78 100644 --- a/recipes/demo/tests_demo/runner_demo.py +++ b/recipes/demo/tests_demo/runner_demo.py @@ -4,7 +4,7 @@ from abratest.runner import Runner, Test class RunnerDemo(Runner): """Every env file has a corresponding runner class""" - name: str = "demo" # name of the test, used for logging / output naming + env_type = "demo" # name of the test, used for logging / output naming # this indicates that tests from RunnerDemo depend on the setup from RunnerAuthentik. # RunnerDemo will only execute, when setup_authentik.py has finished successfully. diff --git a/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py b/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py index aa4e89a..5f7fe27 100644 --- a/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py +++ b/recipes/nextcloud/tests_nextcloud/runner_nextcloud.py @@ -6,7 +6,7 @@ def condition_always_false(dotenv_config: dict[str, str]) -> bool: class RunnerNextcloud(Runner): - name: str = "nextcloud" + env_type = "nextcloud" dependencies = ["authentik"] setups = [Test(test_file="setup_nextcloud.py", prevent_skip=False)] tests = [ diff --git a/recipes/wordpress/tests_wordpress/runner_wordpress.py b/recipes/wordpress/tests_wordpress/runner_wordpress.py index 9813142..846f069 100644 --- a/recipes/wordpress/tests_wordpress/runner_wordpress.py +++ b/recipes/wordpress/tests_wordpress/runner_wordpress.py @@ -17,7 +17,7 @@ def condition_has_locale(dotenv_config: dict[str, str]) -> bool: class RunnerWordpress(Runner): - name = "wordpress" + env_type = "wordpress" dependencies = ["authentik"] setups = [Test(test_file="setup_wordpress.py")] tests = [ -- 2.47.2 From d196d2a1e4d8f99a7bb9bd2d90c3007cb41a722d Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:32:07 +0100 Subject: [PATCH 06/16] use unique names for copied env files, use DIR.ENV_FILES --- abratest/env_manager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/abratest/env_manager.py b/abratest/env_manager.py index 00d412e..2cbcbf1 100644 --- a/abratest/env_manager.py +++ b/abratest/env_manager.py @@ -94,7 +94,7 @@ class EnvManager: def copy_env_files(self, DIR: DirManager) -> None: """Copies all env files to STATES/env_files. Files will be renamed to their own TYPE value.""" - env_files_dir = DIR.STATES / "env_files" - env_files_dir.mkdir(exist_ok=True) - for env_file in self.env_files: - shutil.copy(env_file.env_path, env_files_dir / env_file.env_type) + for index, env_file in enumerate(self.env_files): + # will create something like 00-authentik-login.test.dev.local-it.cloud.env + file_name = "-".join([str(index).zfill(2), env_file.env_type, env_file.env_path.name]) + shutil.copy(env_file.env_path, DIR.ENV_FILES / file_name) -- 2.47.2 From 704af5b32ca928c7dfa2331c0fea8ca049734ab6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:33:06 +0100 Subject: [PATCH 07/16] improve docstring --- abratest/env_manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/abratest/env_manager.py b/abratest/env_manager.py index 2cbcbf1..780436f 100644 --- a/abratest/env_manager.py +++ b/abratest/env_manager.py @@ -93,8 +93,10 @@ class EnvManager: ) def copy_env_files(self, DIR: DirManager) -> None: - """Copies all env files to STATES/env_files. Files will be renamed to their own TYPE value.""" + """Copies all env files to STATES/env_files. Files will be renamed to + -- + 00-authentik-login.test.dev.local-it.cloud.env""" + for index, env_file in enumerate(self.env_files): - # will create something like 00-authentik-login.test.dev.local-it.cloud.env file_name = "-".join([str(index).zfill(2), env_file.env_type, env_file.env_path.name]) shutil.copy(env_file.env_path, DIR.ENV_FILES / file_name) -- 2.47.2 From 0e9d0e0334ce5742119d396b2a3cbc00349c813b Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:41:46 +0100 Subject: [PATCH 08/16] fix authentik fixture import --- recipes/nextcloud/tests_nextcloud/conftest.py | 2 +- recipes/wordpress/tests_wordpress/conftest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/nextcloud/tests_nextcloud/conftest.py b/recipes/nextcloud/tests_nextcloud/conftest.py index 88f5b09..abdf9f9 100644 --- a/recipes/nextcloud/tests_nextcloud/conftest.py +++ b/recipes/nextcloud/tests_nextcloud/conftest.py @@ -7,7 +7,7 @@ from playwright.sync_api import BrowserContext, Page from abratest.dir_manager import DirManager from abratest.utils import BaseUrl -pytest_plugins = "tests_authentik.fixtures_authentik" +pytest_plugins = "authentik.tests_authentik.fixtures_authentik" NEXTCLOUD_DEMO_USER = { "NEXTCLOUD_USER": "next_demo_user", diff --git a/recipes/wordpress/tests_wordpress/conftest.py b/recipes/wordpress/tests_wordpress/conftest.py index db4e529..c91a525 100644 --- a/recipes/wordpress/tests_wordpress/conftest.py +++ b/recipes/wordpress/tests_wordpress/conftest.py @@ -6,7 +6,7 @@ from playwright.sync_api import BrowserContext, Page from abratest.dir_manager import DirManager -pytest_plugins = "tests_authentik.fixtures_authentik" +pytest_plugins = "authentik.tests_authentik.fixtures_authentik" @pytest.fixture -- 2.47.2 From ef0d9c9415ee50905881c1351545c6982780e402 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:44:49 +0100 Subject: [PATCH 09/16] add get_config --- abratest/dir_manager.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/abratest/dir_manager.py b/abratest/dir_manager.py index e172ef5..2104a68 100644 --- a/abratest/dir_manager.py +++ b/abratest/dir_manager.py @@ -1,5 +1,7 @@ from pathlib import Path +from dotenv import dotenv_values + class DirManager: """Manages directories for the tests and should be used to create and find @@ -69,3 +71,8 @@ class DirManager: @property def RECIPES(self): return self.recipes_dir + + def get_config(self, search_string: str) -> dict[str, str]: + env_file = next(self.ENV_FILES.glob(f"*{search_string}*")) + config: dict[str, str] = dotenv_values(env_file) # type: ignore + return config -- 2.47.2 From db2a34c7a7a8f6264d8562ce466954e3c5ebc8b2 Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:46:39 +0100 Subject: [PATCH 10/16] use get_config and BaseUrl in fixtures --- .../tests_authentik/fixtures_authentik.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/recipes/authentik/tests_authentik/fixtures_authentik.py b/recipes/authentik/tests_authentik/fixtures_authentik.py index 3f27b43..34ed3d7 100644 --- a/recipes/authentik/tests_authentik/fixtures_authentik.py +++ b/recipes/authentik/tests_authentik/fixtures_authentik.py @@ -1,10 +1,10 @@ import json import pytest -from dotenv import dotenv_values from playwright.sync_api import BrowserContext, Page from abratest.dir_manager import DirManager +from abratest.utils import BaseUrl @pytest.fixture @@ -18,10 +18,9 @@ def authentik_admin_context(context: BrowserContext, DIR: DirManager) -> Browser @pytest.fixture def authentik_admin_page(authentik_admin_context: BrowserContext, DIR: DirManager) -> Page: page = authentik_admin_context.new_page() - env_file = DIR.ENV_FILES / "authentik" - config: dict[str, str] = dotenv_values(env_file) # type: ignore - url = "https://" + config["DOMAIN"] - page.goto(url) + config = DIR.get_config("authentik") + base_url = BaseUrl(config["DOMAIN"]) + page.goto(base_url.get()) return page @@ -36,8 +35,7 @@ def authentik_user_context(context: BrowserContext, DIR: DirManager) -> BrowserC @pytest.fixture def authentik_user_page(authentik_user_context: BrowserContext, DIR: DirManager) -> Page: page = authentik_user_context.new_page() - env_file = DIR.ENV_FILES / "authentik" - config: dict[str, str] = dotenv_values(env_file) # type: ignore - url = "https://" + config["DOMAIN"] - page.goto(url) + config = DIR.get_config("authentik") + base_url = BaseUrl(config["DOMAIN"]) + page.goto(base_url.get()) return page -- 2.47.2 From 1bc8849cc96172f4a02012c4d68ad7664834d9db Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Dec 2023 23:56:44 +0100 Subject: [PATCH 11/16] remove _dependency_runners from runner --- abratest/coordinator.py | 7 +------ abratest/runner.py | 5 +++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/abratest/coordinator.py b/abratest/coordinator.py index 82fda18..28a5102 100644 --- a/abratest/coordinator.py +++ b/abratest/coordinator.py @@ -44,12 +44,7 @@ class Coordinator: runners: list[Runner] = [] for index, env_file in enumerate(env_files): RunnerClass = self.RUNNER_DICT[env_file.config["TYPE"]] - dependency_classes: list[type[Runner]] = [] - for dependency in RunnerClass.dependencies: - dependency_classes.append(self.RUNNER_DICT[dependency]) - runner_instance = RunnerClass(coordinator=self, runner_index=index) - runner_instance._dependency_runners = dependency_classes - runners.append(runner_instance) + runners.append(RunnerClass(coordinator=self, runner_index=index)) return runners def combine_html(self) -> None: diff --git a/abratest/runner.py b/abratest/runner.py index f69186b..c9cbc9e 100644 --- a/abratest/runner.py +++ b/abratest/runner.py @@ -23,7 +23,6 @@ class Runner: tests: list[Test] = [] cleanups: list[Test] = [] dependencies: list[str] = [] - _dependency_runners: list[type["Runner"]] = [] def __init__(self, coordinator: "Coordinator", runner_index: int): self.coordinator = coordinator # needed? @@ -31,6 +30,7 @@ class Runner: self.DIR = coordinator.DIR self.ENV = coordinator.ENV + self.RUNNER_DICT = coordinator.RUNNER_DICT self.env_file: EnvFile = self.ENV.env_files[self.runner_index] self.dotenv_path = self.env_file.env_path @@ -175,7 +175,8 @@ class Runner: passed_tests = [r.name for r in self.DIR.RESULTS.glob("*") if "passed" in r.name] results = [] - for dependency_runner in self._dependency_runners: + for dependency in self.dependencies: + dependency_runner = self.coordinator.RUNNER_DICT[dependency] for setup_name in dependency_runner.setups: dependencie_identifier = self.combine_names(dependency_runner.env_type, setup_name.test_file) results.append(any(dependencie_identifier in f for f in passed_tests)) -- 2.47.2 From 15a2b2777f3653d251fa411e5d7dd48af2199184 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Dec 2023 01:43:43 +0100 Subject: [PATCH 12/16] add run.sh for docker, adding recipes dir to PYTHONPATH --- run.sh | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 run.sh diff --git a/run.sh b/run.sh new file mode 100644 index 0000000..ddffb80 --- /dev/null +++ b/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +RECIPES_PATH=$PWD/recipes +export PYTHONPATH=${PYTHONPATH}:$RECIPES_PATH + +python main.py \ No newline at end of file -- 2.47.2 From f17c220cb148b0a81bd6bbc95ace267c0190db9b Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Dec 2023 01:53:44 +0100 Subject: [PATCH 13/16] update readme with scripts --- README.md | 4 ++-- run.sh => run_abratest.sh | 0 test_abratest.sh | 7 +++++++ 3 files changed, 9 insertions(+), 2 deletions(-) rename run.sh => run_abratest.sh (100%) create mode 100644 test_abratest.sh diff --git a/README.md b/README.md index 54547be..cd41a3a 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,8 @@ pytest # test abratest ```bash docker compose build # build the image -docker compose run --rm app python ./main.py # run AbraTest -docker compose run --rm app pytest # test AbraTest +docker compose run --rm app ./run_abratest.sh # run AbraTest +docker compose run --rm app ./test_abratest.sh # test AbraTest ``` Force rebuild with cache diff --git a/run.sh b/run_abratest.sh similarity index 100% rename from run.sh rename to run_abratest.sh diff --git a/test_abratest.sh b/test_abratest.sh new file mode 100644 index 0000000..24cef82 --- /dev/null +++ b/test_abratest.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +PWD_PATH=$PWD +RECIPES_PATH=$PWD/recipes +export PYTHONPATH=${PYTHONPATH}:$PWD_PATH:$RECIPES_PATH + +pytest \ No newline at end of file -- 2.47.2 From b220bc7d7e9b784ce9598d86682d0252e40c81d1 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Dec 2023 11:59:45 +0100 Subject: [PATCH 14/16] narrow down pytest search dirs to reduce execution time, especially in docker --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 24f1aa4..ec0809f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,4 +20,5 @@ target-version = "py311" [tool.pytest.ini_options] python_functions = "test_* setup_*" -norecursedirs = "previous-work recipes" \ No newline at end of file +norecursedirs = ".* previous-work recipes" +testpaths = "tests" \ No newline at end of file -- 2.47.2 From 87ddae8006ee5151e434585b53b37d6e8293e2d7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Dec 2023 12:00:19 +0100 Subject: [PATCH 15/16] remove dir --- test_abratest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_abratest.sh b/test_abratest.sh index 24cef82..d7abaaa 100644 --- a/test_abratest.sh +++ b/test_abratest.sh @@ -2,6 +2,6 @@ PWD_PATH=$PWD RECIPES_PATH=$PWD/recipes -export PYTHONPATH=${PYTHONPATH}:$PWD_PATH:$RECIPES_PATH +export PYTHONPATH=$PWD_PATH:$RECIPES_PATH pytest \ No newline at end of file -- 2.47.2 From 532f30d553cc036157fc65e1c625d4c7f981b4c8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 6 Dec 2023 12:01:00 +0100 Subject: [PATCH 16/16] add pytest --collect-only --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cd41a3a..2ceb297 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ Run the script with ```bash python main.py # run abratest pytest # test abratest +pytest --collect-only # debug test abratest ``` # 2.2 Run with Docker -- 2.47.2