Skip to content

Commit

Permalink
Add support for full set of 32 states (#422)
Browse files Browse the repository at this point in the history
Remove unnecessary truncation of the zone states, and add test coverage
for higher numbered zones.

Fixes #315
  • Loading branch information
allenporter committed May 10, 2024
1 parent c6586da commit d274c10
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyrainbird/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ async def get_zone_states(self) -> States:
]
)
return await self._process_command(
lambda resp: States((mask % resp["activeStations"])[:6]),
lambda resp: States((mask % resp["activeStations"])),
"CurrentStationsActiveRequest",
0,
)
Expand Down
25 changes: 24 additions & 1 deletion tests/test_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ async def test_get_zone_state(
assert await controller.get_zone_state(j) == (i == j)


@pytest.mark.parametrize(
("sip_data", "active_zones"),
[
("BF0000000000", []),
("BF0000010000", [9]),
("BF0000000001", [25]),
("BF0000000002", [26]),
("BF0000000004", [27]),
("BF0000381000", [12, 13, 14, 21]),
],
)
async def test_get_zone_state_lxivm(
rainbird_controller: Callable[[], Awaitable[AsyncRainbirdController]],
sip_data_responses: Callable[[list[str]], None],
sip_data: str,
active_zones: list[int],
) -> None:
controller = await rainbird_controller()
sip_data_responses([sip_data])
zone_states = await controller.get_zone_states()
active_states = sorted(list(zone_states.active_set))
assert active_states == active_zones


async def test_set_program(
rainbird_controller: Callable[[], Awaitable[AsyncRainbirdController]],
api_response: Callable[[...], Awaitable[None]],
Expand Down Expand Up @@ -1273,7 +1297,6 @@ async def test_custom_schedule_in_past(
]



@freeze_time("2023-01-25 20:00:00")
async def test_get_schedule_parse_failure(
rainbird_controller: Callable[[], Awaitable[AsyncRainbirdController]],
Expand Down

0 comments on commit d274c10

Please sign in to comment.