diff --git a/tests/test_dem.py b/tests/test_dem.py index ca4f6c0..4a35c0f 100644 --- a/tests/test_dem.py +++ b/tests/test_dem.py @@ -1,3 +1,5 @@ +import pytest + from pathlib import Path from unittest import mock @@ -19,3 +21,26 @@ def test_download_dem_for_srg(monkeypatch): [str(Path.cwd() / 'elevation.dem'), str(Path.cwd() / 'elevation.dem.rsc'), 3, 1, 0, 2], work_dir=Path.cwd(), ) + + +def test_download_dem_from_bounds(monkeypatch): + with monkeypatch.context() as m: + mock_ensure_egm_model_available = mock.Mock() + m.setattr(dem, 'ensure_egm_model_available', mock_ensure_egm_model_available) + mock_call_stanford_module = mock.Mock() + m.setattr(utils, 'call_stanford_module', mock_call_stanford_module) + dem.download_dem_from_bounds([1.0, 0.0, -1.0, 1.0], Path.cwd()) + mock_ensure_egm_model_available.assert_called_once() + mock_call_stanford_module.assert_called_once_with( + 'DEM/createDEMcop.py', + [str(Path.cwd() / 'elevation.dem'), str(Path.cwd() / 'elevation.dem.rsc'), 1.0, 0.0, -1.0, 1.0], + work_dir=Path.cwd(), + ) + bad_bboxs = [ + [0.0, 1.0, -1.0, 1.0], + [1.0, 1.0, -1.0, 1.0], + [1.0, 0.0, 1.0, -1.0] + ] + for bbox in bad_bboxs: + with pytest.raises(ValueError, match=r'Improper bounding box formatting*'): + dem.download_dem_from_bounds(bbox, Path.cwd())