Skip to content

Commit

Permalink
Merge pull request #625 from ungarj/fix_624_extend_env_variables
Browse files Browse the repository at this point in the history
add test to verify that all process config parameters can be set from…
  • Loading branch information
ungarj authored Feb 27, 2024
2 parents 593bf3c + 7edbc99 commit 5f5963b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ markers =
env =
D:AK1=foo
D:AK2=bar
D:FILE1=dummy2.tif
addopts = --durations 20 --verbose --nf --cov=mapchete
9 changes: 9 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
9 changes: 8 additions & 1 deletion test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
13 changes: 13 additions & 0 deletions test/testdata/env_input_path.mapchete
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5f5963b

Please sign in to comment.