Test invalid payload type for websocket subscription

This commit is contained in:
marvin-w
2022-08-12 20:34:16 +02:00
committed by Marvin Wichmann
parent 78524d8f83
commit 09d1c90e67
2 changed files with 22 additions and 2 deletions
+20 -1
View File
@@ -11,7 +11,13 @@ from xknx.dpt import DPTArray, DPTBinary
from xknx.io import DEFAULT_MCAST_GRP, DEFAULT_MCAST_PORT
from xknx.telegram import Telegram, TelegramDirection
from xknx.telegram.address import GroupAddress, IndividualAddress
from xknx.telegram.apci import APCI, GroupValueRead, GroupValueResponse, GroupValueWrite
from xknx.telegram.apci import (
APCI,
GroupValueRead,
GroupValueResponse,
GroupValueWrite,
IndividualAddressRead,
)
from homeassistant.components.knx.const import (
CONF_KNX_AUTOMATIC,
@@ -188,6 +194,19 @@ class KNXTestKit:
await self.xknx.telegrams.join()
await self.hass.async_block_till_done()
async def receive_individual_address_read(self):
"""Inject incoming IndividualAddressRead telegram."""
self.xknx.telegrams.put_nowait(
Telegram(
destination_address=IndividualAddress(self.INDIVIDUAL_ADDRESS),
direction=TelegramDirection.INCOMING,
payload=IndividualAddressRead(),
source_address=IndividualAddress("1.3.5"),
)
)
await self.xknx.telegrams.join()
await self.hass.async_block_till_done()
async def receive_read(
self,
group_address: str,
+2 -1
View File
@@ -46,6 +46,7 @@ async def test_knx_subscribe_telegrams_command(
await knx.receive_read("1/2/3")
await knx.receive_write("1/3/4", True)
await knx.receive_write("1/3/4", False)
await knx.receive_individual_address_read()
await knx.receive_write("1/3/8", (0x34, 0x45))
# send outgoing events
await hass.services.async_call(
@@ -92,6 +93,6 @@ async def test_knx_subscribe_telegrams_command(
assert res["event"]["type"] == "GroupValueWrite"
assert (
res["event"]["source_address"] == "0.0.0"
) # needs to be the currently connected IA connected to
) # needs to be the IA currently connected to
assert res["event"]["direction"] == "label.outgoing"
assert res["event"]["timestamp"] is not None