Skip to content

Commit

Permalink
Add optional ldd configuration setting test
Browse files Browse the repository at this point in the history
  • Loading branch information
soaressgabriel committed Feb 22, 2024
1 parent 6e59bde commit 33e544b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/unit/configuration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
"rasters": {
"dem": {"min": -100.0, "max": 10000.0},
"ldd": {"min": 1, "max": 9},
"clone": {"min": 0.0, "max": 1.0},
"ndvi": {"min": -1.0, "max": 1.0},
"soil": {"min": 0.0, "max": "Infinity"},
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/configuration/test_model_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,19 @@ def test_init_with_dictionary(self, mocker):
mocker.patch("rubem.configuration.raster_map.RasterBand", return_value=band_mock)
_ = ModelConfiguration(self.valid_config_input)

@pytest.mark.unit
def test_init_with_dictionary_optional_ldd(self, mocker):
band_mock = MagicMock(spec=RasterBand)
band_mock.no_data_value = -9999
band_mock.data_array = np.ones((3, 3))
mocker.patch("osgeo.gdal.OpenEx")
mocker.patch("osgeo.gdal.GetDataTypeName")
mocker.patch("os.path.getsize", return_value=100)
mocker.patch("rubem.configuration.raster_map.RasterBand", return_value=band_mock)
input_dict = self.valid_config_input.copy()
input_dict["RASTERS"]["ldd"] = "test_path/test_file.map"
_ = ModelConfiguration(input_dict)

@pytest.mark.unit
def test_init_with_empty_dictionary(self):
with pytest.raises(Exception):
Expand Down

0 comments on commit 33e544b

Please sign in to comment.