From 1b82997dcb6cd5185e7a3653ee95bce7abb8589c Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 16 Oct 2024 13:57:07 -0400 Subject: [PATCH] Fix unit tests --- tests/conftest.py | 29 ++++++++++++++++++----------- zigpy_znp/zigbee/device.py | 22 +++++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1a2f730f..274478af 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -129,13 +129,16 @@ def __repr__(self): return f"<{type(self).__name__} to {self.protocol}>" -def config_for_port_path(path): - return conf.CONFIG_SCHEMA( - { - conf.CONF_DEVICE: {conf.CONF_DEVICE_PATH: path}, - zigpy.config.CONF_NWK_BACKUP_ENABLED: False, - } - ) +def config_for_port_path(path, apply_schema: bool = True): + config = { + conf.CONF_DEVICE: {conf.CONF_DEVICE_PATH: path}, + zigpy.config.CONF_NWK_BACKUP_ENABLED: False, + } + + if apply_schema: + return conf.CONFIG_SCHEMA(config) + + return config @pytest.fixture @@ -272,10 +275,14 @@ def inner( server_config=None, **kwargs, ): - default = config_for_port_path(FAKE_SERIAL_PORT) - - client_config = merge_dicts(default, client_config or {}) - server_config = merge_dicts(default, server_config or {}) + client_config = merge_dicts( + config_for_port_path(FAKE_SERIAL_PORT, apply_schema=False), + client_config or {}, + ) + server_config = merge_dicts( + config_for_port_path(FAKE_SERIAL_PORT), + server_config or {}, + ) app = ControllerApplication(client_config) diff --git a/zigpy_znp/zigbee/device.py b/zigpy_znp/zigbee/device.py index f6c7a4c6..401baacc 100644 --- a/zigpy_znp/zigbee/device.py +++ b/zigpy_znp/zigbee/device.py @@ -3,6 +3,7 @@ import logging import zigpy.zdo +import zigpy.types import zigpy.device import zigpy.application @@ -22,7 +23,7 @@ def manufacturer(self): def model(self): return "Coordinator" - def request( + async def request( self, profile, cluster, @@ -31,22 +32,25 @@ def request( sequence, data, expect_reply=True, - # Extend the default timeout timeout=2 * zigpy.device.APS_REPLY_TIMEOUT, use_ieee=False, + ask_for_ack: bool | None = None, + priority: int = zigpy.types.PacketPriority.NORMAL, ): """ Normal `zigpy.device.Device:request` except its default timeout is longer. """ - return super().request( - profile, - cluster, - src_ep, - dst_ep, - sequence, - data, + return await super().request( + profile=profile, + cluster=cluster, + src_ep=src_ep, + dst_ep=dst_ep, + sequence=sequence, + data=data, expect_reply=expect_reply, timeout=timeout, use_ieee=use_ieee, + ask_for_ack=ask_for_ack, + priority=priority, )