Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey committed Aug 6, 2024
1 parent 9941ff8 commit 9fe8345
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,41 @@ async def test_gateway_startup_failure(
assert zha_gateway.shutdown.await_count == 1


@pytest.mark.parametrize(("enabled", "await_count"), [(True, 1), (False, 0)])
async def test_mains_devices_startup_polling_config(
zha_data: ZHAData,
zigpy_app_controller: ControllerApplication,
enabled: bool,
await_count: int,
) -> None:
"""Test mains powered device startup polling config is respected."""

with (
patch(
"bellows.zigbee.application.ControllerApplication.new",
return_value=zigpy_app_controller,
),
patch(
"bellows.zigbee.application.ControllerApplication",
return_value=zigpy_app_controller,
),
):
zha_data.config.device_options.allow_mains_startup_polling = enabled
zha_gateway = await Gateway.async_from_config(zha_data)
zha_gateway.async_fetch_updated_state_mains = AsyncMock(
wraps=zha_gateway.async_fetch_updated_state_mains
)
await zha_gateway.async_initialize()
await zha_gateway.async_block_till_done()
await zha_gateway.async_initialize_devices_and_entities()
await zha_gateway.async_block_till_done()

assert zha_gateway.async_fetch_updated_state_mains.await_count == await_count

await zha_gateway.shutdown()
await zha_gateway.async_block_till_done()


async def test_gateway_group_methods(
zha_gateway: Gateway,
device_light_1, # pylint: disable=redefined-outer-name
Expand Down

0 comments on commit 9fe8345

Please sign in to comment.