Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rgc99 committed Dec 28, 2023
1 parent 9dcbea9 commit c63e232
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
4 changes: 4 additions & 0 deletions tests/configs/test_volume_extensive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ irrigation_unlimited:
timeline: true
volume:
entity_id: "input_text.dummy_sensor"
volume_scale: 1000
volume_precision: 0
flow_rate_scale: 60
flow_rate_precision: 1
allow_manual: true
# duration: "0:10:00"
zones:
Expand Down
59 changes: 53 additions & 6 deletions tests/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def read_data(file: str) -> tuple[datetime, str, str]:
controller_flows: list[float] = []
zone_volumes: list[float] = []
zone_flows: list[float] = []
sequence_volumes: list[float] = []

with patch.object(IUVolume, "event_hook") as mock:
zone: int = None
Expand Down Expand Up @@ -278,6 +279,8 @@ def state_change(event: ha.Event) -> ha.Event:
)
zone_volumes.append(sta.attributes["volume"])
zone_flows.append(sta.attributes["flow_rate"])
sta = hass.states.get("binary_sensor.irrigation_unlimited_c1_s1")
sequence_volumes.append(sta.attributes["volume"])
sta = hass.states.get("binary_sensor.irrigation_unlimited_c1_m")
controller_volumes.append(sta.attributes["volume"])
controller_flows.append(sta.attributes["flow_rate"])
Expand All @@ -287,7 +290,7 @@ def state_change(event: ha.Event) -> ha.Event:
await asyncio.sleep(0)
trackers_processed = 0

volume_results = [
assert controller_volumes == [
0.128,
0.121,
0.060,
Expand All @@ -302,10 +305,40 @@ def state_change(event: ha.Event) -> ha.Event:
0.072,
0.671,
]
assert controller_volumes == volume_results
assert zone_volumes == volume_results

flow_results = [
assert zone_volumes == [
128.0,
121.0,
60.0,
71.0,
30.0,
58.0,
95.0,
56.0,
134.0,
45.0,
31.0,
72.0,
671.0,
]

assert sequence_volumes == [
128.0,
249.0,
309.0,
380.0,
410.0,
468.0,
563.0,
619.0,
753.0,
798.0,
829.0,
901.0,
1572.0,
]

assert controller_flows == [
0.29,
0.401,
0.136,
Expand All @@ -320,8 +353,22 @@ def state_change(event: ha.Event) -> ha.Event:
0.154,
1.119,
]
assert controller_flows == flow_results
assert zone_flows == flow_results

assert zone_flows == [
4.8,
6.7,
2.3,
2.5,
1.6,
1.5,
2.5,
2.1,
5.9,
5.1,
1.1,
2.6,
18.7,
]

await exam.finish_test()

Expand Down

0 comments on commit c63e232

Please sign in to comment.