From 7edbc99a8ea3b18c30cdae6122b6e608714cf1ad Mon Sep 17 00:00:00 2001 From: Joachim Ungar Date: Tue, 27 Feb 2024 10:39:03 +0100 Subject: [PATCH] add test to verify that all process config parameters can be set from environment --- pytest.ini | 1 + test/conftest.py | 9 +++++++++ test/test_config.py | 9 ++++++++- test/testdata/env_input_path.mapchete | 13 +++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/testdata/env_input_path.mapchete diff --git a/pytest.ini b/pytest.ini index e865bb36..5f98ac1a 100644 --- a/pytest.ini +++ b/pytest.ini @@ -5,4 +5,5 @@ markers = env = D:AK1=foo D:AK2=bar + D:FILE1=dummy2.tif addopts = --durations 20 --verbose --nf --cov=mapchete \ No newline at end of file diff --git a/test/conftest.py b/test/conftest.py index 2a2f6bbc..988c5e76 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -729,6 +729,15 @@ def env_storage_options_mapchete(mp_tmpdir): yield example +@pytest.fixture +def env_input_path_mapchete(mp_tmpdir): + """Fixture for env_input_path.mapchete.""" + with ProcessFixture( + TESTDATA_DIR / "env_input_path.mapchete", output_tempdir=mp_tmpdir + ) as example: + yield example + + @pytest.fixture def example_custom_process_mapchete(mp_tmpdir): """Fixture for example.mapchete.""" diff --git a/test/test_config.py b/test/test_config.py index 7a31b22e..40f54b7e 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -482,13 +482,20 @@ def test_custom_process(example_custom_process_mapchete): # pytest-env must be installed -def test_env_params(env_storage_options_mapchete): +def test_env_storage_options(env_storage_options_mapchete): with mapchete.open(env_storage_options_mapchete.dict) as mp: inp = mp.config.params_at_zoom(5) assert inp["input"]["file1"].storage_options.get("access_key") == "foo" assert mp.config.output.storage_options.get("access_key") == "bar" +# pytest-env must be installed +def test_env_params(env_input_path_mapchete): + with mapchete.open(env_input_path_mapchete.dict) as mp: + inp = mp.config.params_at_zoom(5) + assert inp["input"]["file1"].path.endswith("dummy2.tif") + + def test_process_config_pyramid_settings(): conf = ProcessConfig( pyramid=dict( diff --git a/test/testdata/env_input_path.mapchete b/test/testdata/env_input_path.mapchete new file mode 100644 index 00000000..b07082fd --- /dev/null +++ b/test/testdata/env_input_path.mapchete @@ -0,0 +1,13 @@ +process: ../example_process.py +zoom_levels: 5 +pyramid: + grid: geodetic +input: + file1: + format: raster_file + path: ${FILE1} +output: + dtype: float32 + bands: 1 + format: GTiff + path: tmp/gtiff