Skip to content

Commit

Permalink
Add unit test for initializing ModelConfiguration with optional sam…
Browse files Browse the repository at this point in the history
…ples raster
  • Loading branch information
soaressgabriel committed Feb 23, 2024
1 parent 531aaac commit d067a33
Showing 1 changed file with 13 additions and 0 deletions.
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 @@ -287,6 +287,19 @@ def test_init_with_dictionary_optional_ldd(self, mocker):
input_dict["RASTERS"]["ldd"] = "test_path/test_file.map"
_ = ModelConfiguration(input_dict)

@pytest.mark.unit
def test_init_with_dictionary_optional_samples(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"]["samples"] = None
_ = ModelConfiguration(input_dict)

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

0 comments on commit d067a33

Please sign in to comment.