-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_dem.py
37 lines (33 loc) · 1.25 KB
/
test_dem.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from pathlib import Path
from unittest import mock
import pytest
from shapely.geometry import box
from hyp3_srg import dem, utils
def test_download_dem_for_srg(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_for_srg(list(box(0, 1, 2, 3).bounds), 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'),
3,
1,
0,
2,
],
work_dir=Path.cwd(),
)
bad_bboxs = [
[0.0, 1.0, -1.0, 1.0],
[1.0, 1.0, -1.0, 2.0],
[1.0, 0.0, 2.0, -1.0],
]
for bbox in bad_bboxs:
with pytest.raises(ValueError, match=r'Improper bounding box formatting*'):
dem.download_dem_for_srg(bbox, Path.cwd())