async def test_dynalite_devices_active(mock_gateway, active): """Test with active set to ON.""" [_, _, device_pres] = mock_gateway.configure_dyn_dev( { dyn_const.CONF_ACTIVE: active, dyn_const.CONF_AREA: { "1": { dyn_const.CONF_CHANNEL: { "1": {}, "2": {} } } }, dyn_const.CONF_PRESET: { "1": {} }, }, 3, ) assert await mock_gateway.async_setup_dyn_dev() await mock_gateway.check_single_update(None) if active is not False: await mock_gateway.check_writes([ DynetPacket.request_channel_level_packet(1, 1), DynetPacket.request_channel_level_packet(1, 2), DynetPacket.request_area_preset_packet(1, 1), ]) else: await mock_gateway.check_writes([]) packet_to_send = DynetPacket.report_area_preset_packet(1, 1) await mock_gateway.receive(packet_to_send) await mock_gateway.check_single_update(device_pres) await mock_gateway.check_notifications([ packet_notification(packet_to_send.raw_msg), preset_notification(1, 1) ]) if active is True: await mock_gateway.check_writes([ DynetPacket.request_channel_level_packet(1, 1), DynetPacket.request_channel_level_packet(1, 2), ]) else: await mock_gateway.check_writes([])
async def test_inbound_request_channel_level(mock_gateway): """Test when the network requests a channel level. Nothing to do, just be sure nothing bad happens...""" [device] = mock_gateway.configure_dyn_dev( { dyn_const.CONF_ACTIVE: False, dyn_const.CONF_AREA: {"3": {dyn_const.CONF_CHANNEL: {"5": {}}}}, dyn_const.CONF_PRESET: {}, }, 1, ) assert not device.is_on assert await mock_gateway.async_setup_dyn_dev() await mock_gateway.receive(DynetPacket.request_channel_level_packet(3, 5)) assert not device.is_on
async def test_dynalite_devices_active(mock_gateway, active): """Test with active set to ON.""" mock_gateway.configure_dyn_dev( { dyn_const.CONF_ACTIVE: active, dyn_const.CONF_AREA: { "1": { dyn_const.CONF_CHANNEL: { "1": {}, "2": {} } } }, dyn_const.CONF_PRESET: { "1": {} }, }, 3, ) assert await mock_gateway.async_setup_dyn_dev() if active is not False: await mock_gateway.check_writes([ DynetPacket.request_channel_level_packet(1, 1), DynetPacket.request_channel_level_packet(1, 2), DynetPacket.request_area_preset_packet(1), ]) else: await mock_gateway.check_writes([]) await mock_gateway.receive(DynetPacket.report_area_preset_packet(1, 1)) if active is True: await mock_gateway.check_writes([ DynetPacket.request_channel_level_packet(1, 1), DynetPacket.request_channel_level_packet(1, 2), ]) else: await mock_gateway.check_writes([])