From 488e9bf34936c594ce8310b8ad5c03a22ddbcbac Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Tue, 23 Jan 2024 14:37:33 +0100 Subject: [PATCH] fixup! Refactor process test example parsing/listing to openeo_test_suite.lib.processes.registry --- .github/workflows/internal-tests.yaml | 4 +--- .github/workflows/pytest-collect.yaml | 2 ++ .../lib/processes/registry.py | 20 ++++++++++++++++--- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.github/workflows/internal-tests.yaml b/.github/workflows/internal-tests.yaml index b4dba1d..cd5f8f4 100644 --- a/.github/workflows/internal-tests.yaml +++ b/.github/workflows/internal-tests.yaml @@ -29,6 +29,4 @@ jobs: python -m pip install --upgrade pip python -m pip install . - name: "Internal tests" - run: | - export OPENEO_TEST_SUITE_PROCESSES_TEST_ROOT=assets/processes/tests - pytest src/openeo_test_suite/lib/internal-tests/ + run: pytest src/openeo_test_suite/lib/internal-tests/ diff --git a/.github/workflows/pytest-collect.yaml b/.github/workflows/pytest-collect.yaml index 39a6838..8fdfc44 100644 --- a/.github/workflows/pytest-collect.yaml +++ b/.github/workflows/pytest-collect.yaml @@ -13,6 +13,8 @@ jobs: steps: - name: Clone repo uses: actions/checkout@v2 + with: + submodules: recursive - name: Set up python uses: actions/setup-python@v4 with: diff --git a/src/openeo_test_suite/lib/processes/registry.py b/src/openeo_test_suite/lib/processes/registry.py index 200153f..5f50636 100644 --- a/src/openeo_test_suite/lib/processes/registry.py +++ b/src/openeo_test_suite/lib/processes/registry.py @@ -33,10 +33,24 @@ def __init__(self, root: Optional[Path] = None): """ self._root = Path( root - # TODO: eliminate need for this env var + # TODO: eliminate need for this env var? or os.environ.get("OPENEO_TEST_SUITE_PROCESSES_TEST_ROOT") - # TODO: make this default path compatible with packaging - or (Path(openeo_test_suite.__file__).parents[2] / "assets/processes/tests") + or self._guess_root() + ) + + def _guess_root(self): + # TODO: avoid need for guessing and properly include assets in (installed) package + project_root = Path(openeo_test_suite.__file__).parents[2] + candidates = [ + project_root / "assets/processes/tests", + Path("./assets/processes/tests"), + Path("./openeo-test-suite/assets/processes/tests"), + ] + for candidate in candidates: + if candidate.exists() and candidate.is_dir(): + return candidate + raise ValueError( + f"Could not find valid processes test root directory (tried {candidates})" ) def get_all_processes(self) -> Iterator[ProcessData]: