Skip to content

Commit

Permalink
Move fixtures to core to allow usage in workflows and process metadat…
Browse files Browse the repository at this point in the history
…a, README
  • Loading branch information
m-mohr committed Dec 19, 2023
1 parent bd0b211 commit 239766b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 40 deletions.
38 changes: 38 additions & 0 deletions src/openeo_test_suite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,44 @@ def skip_experimental(request) -> str:
return skip


@pytest.fixture(scope="session")
def process_levels(request):
"""
Fixture to get the desired openEO profiles levels.
"""
levels_str = ""
# TODO: also support getting it from a config file?
if request.config.getoption("--process-levels"):
levels_str = request.config.getoption("--process-levels")
elif "OPENEO_PROCESS_LEVELS" in os.environ:
levels_str = os.environ["OPENEO_PROCESS_LEVELS"]

if isinstance(levels_str, str) and len(levels_str) > 0:
_log.info(f"Testing process levels {levels_str!r}")
return list(map(lambda l: l.strip(), levels_str.split(",")))
else:
return []


@pytest.fixture(scope="session")
def processes(request):
"""
Fixture to get the desired profiles to test against.
"""
processes_str = ""
# TODO: also support getting it from a config file?
if request.config.getoption("--processes"):
processes_str = request.config.getoption("--processes")
elif "OPENEO_PROCESSES" in os.environ:
processes_str = os.environ["OPENEO_PROCESSES"]

if isinstance(processes_str, str) and len(processes_str) > 0:
_log.info(f"Testing processes {processes_str!r}")
return list(map(lambda p: p.strip(), processes_str.split(",")))
else:
return []


@pytest.fixture
def auto_authenticate() -> bool:
"""
Expand Down
7 changes: 5 additions & 2 deletions src/openeo_test_suite/tests/processes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@

## Individual Process Testing

Examples:
### Examples

- `pytest --openeo-backend-url=https://openeo.cloud --processes=min,max`
- `pytest --runner=vito --process-levels=L1,L2,L2A`
- `pytest --runner=dask`
- `pytest src/openeo_test_suite/tests/processes/processing/test_example.py --runner=dask`

Parameters:
### Parameters

Specify `src/openeo_test_suite/tests/processes/processing/test_example.py` to only run individual process tests.

- `--runner`: The execution engine. One of:
- `vito` (needs <https://github.com/Open-EO/openeo-python-driver> being installed)
Expand Down
38 changes: 0 additions & 38 deletions src/openeo_test_suite/tests/processes/processing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,6 @@ def runner(request) -> str:
return runner


@pytest.fixture(scope="session")
def process_levels(request):
"""
Fixture to get the desired openEO profiles levels.
"""
levels_str = ""
# TODO: also support getting it from a config file?
if request.config.getoption("--process-levels"):
levels_str = request.config.getoption("--process-levels")
elif "OPENEO_PROCESS_LEVELS" in os.environ:
levels_str = os.environ["OPENEO_PROCESS_LEVELS"]

if isinstance(levels_str, str) and len(levels_str) > 0:
_log.info(f"Testing process levels {levels_str!r}")
return list(map(lambda l: l.strip(), levels_str.split(",")))
else:
return []


@pytest.fixture(scope="session")
def processes(request):
"""
Fixture to get the desired profiles to test against.
"""
processes_str = ""
# TODO: also support getting it from a config file?
if request.config.getoption("--processes"):
processes_str = request.config.getoption("--processes")
elif "OPENEO_PROCESSES" in os.environ:
processes_str = os.environ["OPENEO_PROCESSES"]

if isinstance(processes_str, str) and len(processes_str) > 0:
_log.info(f"Testing processes {processes_str!r}")
return list(map(lambda p: p.strip(), processes_str.split(",")))
else:
return []


@pytest.fixture
def connection(
backend_url: str, runner: str, auto_authenticate: bool, capfd
Expand Down

0 comments on commit 239766b

Please sign in to comment.