Skip to content

Commit

Permalink
Adding test ids
Browse files Browse the repository at this point in the history
  • Loading branch information
davidorme committed Jan 7, 2025
1 parent c8cd3ae commit 1c54b12
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/core/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,3 +1107,54 @@ def test_merge_continuous_file_already_exists(
),
),
)


@pytest.mark.parametrize(
argnames="vars, var_names, exp_result, exp_msg",
argvalues=[
pytest.param(
{"a": DataArray(np.ones(12)), "b": DataArray(np.ones(12))},
["a", "b"],
True,
"Variables form a data frame",
id="correct",
),
pytest.param(
{"a": DataArray(np.ones(12)), "b": DataArray(np.ones(12))},
["a", "c"],
False,
"Missing variables: c",
id="missing variable",
),
pytest.param(
{"a": DataArray(np.ones((12, 2))), "b": DataArray(np.ones(12))},
["a", "b"],
False,
"Variables not one dimensional: a",
id="not all one dimensional",
),
pytest.param(
{
"a": DataArray(np.ones(14), dims="dim_1"),
"b": DataArray(np.ones(12), dims="dim_2"),
},
["a", "b"],
False,
"Variables of unequal length: 12,14",
id="not equal length",
),
],
)
def test_Data_confirm_variables_form_data_frame(vars, var_names, exp_result, exp_msg):
"""Test the data frame validation mechanism."""

from virtual_ecosystem.core.data import Data
from virtual_ecosystem.core.grid import Grid

data = Data(grid=Grid())
data.add_from_dict(vars)

result, msg = data.confirm_variables_form_data_frame(var_names)

assert result == exp_result
assert msg == exp_msg

0 comments on commit 1c54b12

Please sign in to comment.