Skip to content

Commit

Permalink
negative cases for dem download
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewPlayer3 committed Sep 19, 2024
1 parent 61ef231 commit 7358e60
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_dem.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pytest

from pathlib import Path
from unittest import mock

Expand All @@ -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())

0 comments on commit 7358e60

Please sign in to comment.