Skip to content

Commit

Permalink
Add tests for new set_value input checks
Browse files Browse the repository at this point in the history
  • Loading branch information
BSchilperoort committed Aug 28, 2024
1 parent 09f4304 commit 9b754db
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_bmi_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ def test_set_value(self, updated_model):
updated_model.get_value("soil_temperature", dest)
np.testing.assert_array_equal(src, dest)

def test_wrong_set_value(self, updated_model):
gridsize = updated_model.get_grid_size(
updated_model.get_var_grid("soil_temperature")
)
src = np.zeros(gridsize + 1) + 10.0
with pytest.raises(ValueError, match="not equal"):
updated_model.set_value("soil_temperature", src)

def test_set_value_inds(self, updated_model):
dest = np.zeros(1)
updated_model.set_value_at_indices(
Expand All @@ -292,6 +300,14 @@ def test_set_value_inds(self, updated_model):
updated_model.get_value_at_indices("soil_temperature", dest, inds=np.array([0]))
assert dest[0] == 0.0

def test_wrong_set_value_inds(self, updated_model):
with pytest.raises(ValueError, match="not equal"):
updated_model.set_value_at_indices(
"soil_temperature",
inds=np.array([0, 1]),
src=np.array([0.0]),
)

def test_itemsize(self, updated_model):
assert updated_model.get_var_itemsize("soil_temperature") == 8 # ==64 bits

Expand Down

0 comments on commit 9b754db

Please sign in to comment.