Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lpilz committed Dec 1, 2023
1 parent e5f93fe commit ee35e08
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tests/test_destagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,23 @@ def test_rename_staggered_coordinate(input_name, stagger_dim, unstag_dim_name, o


def test_destag_variable_dataarray():
with pytest.raises(ValueError):
_destag_variable(
xr.DataArray(
np.zeros((2, 2)), dims=('x_stag', 'y'), coords={'x_stag': [0, 1], 'y': [0, 1]}
)
with pytest.raises(ValueError) as exc_info:
mock_da = xr.DataArray(
np.zeros((2, 2)), dims=('x_stag', 'y'), coords={'x_stag': [0, 1], 'y': [0, 1]}
)
_destag_variable(mock_da)
assert (
exc_info.value.args[0] == f'Parameter datavar must be xarray.Variable, not {type(mock_da)}'
)


def test_destag_variable_unstaggered():
with pytest.raises(ValueError) as exc_info:
_destag_variable(xr.Variable(('x', 'y'), np.zeros((2, 2))))
assert (
exc_info.value.args[0]
== 'No dimension available to destagger. This variable does not appear to be staggered.'
)


def test_destag_variable_missing_dim():
Expand Down

0 comments on commit ee35e08

Please sign in to comment.