Skip to content

Commit

Permalink
#105: Add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
priscavdsluis committed Jun 28, 2022
1 parent b2252ac commit b667cfe
Showing 1 changed file with 116 additions and 0 deletions.
116 changes: 116 additions & 0 deletions tests/io/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,8 @@ class DambreakTestCases:
check_location_err = (
"`num/x/yCoordinates` or `polylineFile` are mandatory for a Dambreak structure."
)
check_upstream_waterlevel_location_err="Either `waterLevelUpstreamNodeId` should be specified or `waterLevelUpstreamLocationX` and `waterLevelUpstreamLocationY`."
check_downstream_waterlevel_location_err="Either `waterLevelDownstreamNodeId` should be specified or `waterLevelDownstreamLocationX` and `waterLevelDownstreamLocationY`."
too_few_coords = "Expected at least 2 coordinates, but only {} declared."
mismatch_coords = (
"Expected {} coordinates, given {} for xCoordinates and {} for yCoordinates."
Expand Down Expand Up @@ -1265,6 +1267,120 @@ def test_given_valid_values_returns_values(self, dict_values: dict):
DambreakTestCases.check_location_err,
id="Specified locations None",
),
pytest.param(
dict(
polylinefile=Path(),
waterleveldownstreamnodeid="aDownstreamNodeId"
),
DambreakTestCases.check_upstream_waterlevel_location_err,
id="No upstream water level locations specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterleveldownstreamnodeid="aDownstreamNodeId",
waterlevelupstreamlocationx=1.2
),
DambreakTestCases.check_upstream_waterlevel_location_err,
id="Only upstream water level location x specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterleveldownstreamnodeid="aDownstreamNodeId",
waterlevelupstreamlocationy=2.3
),
DambreakTestCases.check_upstream_waterlevel_location_err,
id="Only upstream water level location y specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterleveldownstreamnodeid="aDownstreamNodeId",
waterlevelupstreamnodeid="anUpstreamNodeId",
waterlevelupstreamlocationx=1.2
),
DambreakTestCases.check_upstream_waterlevel_location_err,
id="Upstream water level location node id and x specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterleveldownstreamnodeid="aDownstreamNodeId",
waterlevelupstreamnodeid="anUpstreamNodeId",
waterlevelupstreamlocationy=2.3
),
DambreakTestCases.check_upstream_waterlevel_location_err,
id="Upstream water level location node id and y specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterleveldownstreamnodeid="aDownstreamNodeId",
waterlevelupstreamnodeid="anUpstreamNodeId",
waterlevelupstreamlocationx=1.2,
waterlevelupstreamlocationy=2.3
),
DambreakTestCases.check_upstream_waterlevel_location_err,
id="Upstream water level location node id, x and y specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterlevelupstreamnodeid="anUpstreamNodeId"
),
DambreakTestCases.check_downstream_waterlevel_location_err,
id="No downstream water level locations specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterlevelupstreamnodeid="anUpstreamNodeId",
waterleveldownstreamlocationx=3.4
),
DambreakTestCases.check_downstream_waterlevel_location_err,
id="Only downstream water level location x specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterlevelupstreamnodeid="anUpstreamNodeId",
waterleveldownstreamlocationy=4.5
),
DambreakTestCases.check_downstream_waterlevel_location_err,
id="Only downstream water level location y specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterlevelupstreamnodeid="anUpstreamNodeId",
waterleveldownstreamnodeid="aDownstreamNodeId",
waterleveldownstreamlocationx=3.4
),
DambreakTestCases.check_downstream_waterlevel_location_err,
id="Downstream water level location node id and x specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterlevelupstreamnodeid="anUpstreamNodeId",
waterleveldownstreamnodeid="aDownstreamNodeId",
waterleveldownstreamlocationy=4.5
),
DambreakTestCases.check_downstream_waterlevel_location_err,
id="Downstream water level location node id and y specified"
),
pytest.param(
dict(
polylinefile=Path(),
waterlevelupstreamnodeid="anUpstreamNodeId",
waterleveldownstreamnodeid="aDownstreamNodeId",
waterleveldownstreamlocationx=3.4,
waterleveldownstreamlocationy=4.5
),
DambreakTestCases.check_downstream_waterlevel_location_err,
id="Downstream water level location node id, x and y specified"
),
],
)
def test_given_invalid_values_raises_expectation(
Expand Down

0 comments on commit b667cfe

Please sign in to comment.