From b658bc1e74c542ff1e4d446550d1bb9d3a2f77cc Mon Sep 17 00:00:00 2001 From: TheJulianJES Date: Thu, 11 Apr 2024 21:45:12 +0200 Subject: [PATCH] Fix tests broken by zigpy update (#246) * Fix watchdog test * Use mock patch annotation for watchdog period * Fix TSNs * Re-add sleep to make sure watchdog loop has enough time for 5 "feeds" --- tests/application/test_connect.py | 8 +++----- tests/application/test_joining.py | 4 ++-- tests/application/test_requests.py | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/application/test_connect.py b/tests/application/test_connect.py index 79fa9104..5c6aa54b 100644 --- a/tests/application/test_connect.py +++ b/tests/application/test_connect.py @@ -201,15 +201,13 @@ async def test_disconnect_failure(device, make_application): @pytest.mark.parametrize("device", [FormedLaunchpadCC26X2R1]) +@patch("zigpy_znp.zigbee.application.ControllerApplication._watchdog_period", new=0.1) async def test_watchdog(device, make_application): app, znp_server = make_application(server_cls=device) - await app.startup(auto_form=False) - app._watchdog_feed = AsyncMock(wraps=app._watchdog_feed) - with patch("zigpy.application.ControllerApplication._watchdog_period", new=0.1): - await asyncio.sleep(0.6) - + await app.startup(auto_form=False) + await asyncio.sleep(0.6) assert len(app._watchdog_feed.mock_calls) >= 5 await app.shutdown() diff --git a/tests/application/test_joining.py b/tests/application/test_joining.py index 6db28283..1523dff0 100644 --- a/tests/application/test_joining.py +++ b/tests/application/test_joining.py @@ -40,7 +40,7 @@ async def test_permit_join(device, mocker, make_application): request=zdo_request_matcher( dst_addr=t.AddrModeAddress(t.AddrMode.Broadcast, 0xFFFC), command_id=zdo_t.ZDOCmd.Mgmt_Permit_Joining_req, - TSN=7, + TSN=2, zdo_PermitDuration=10, zdo_TC_Significant=0, ), @@ -117,7 +117,7 @@ async def test_join_device(device, make_application): IsBroadcast=t.Bool.false, ClusterId=32822, SecurityUse=0, - TSN=7, + TSN=1, MacDst=0x0000, Data=b"\x00", ), diff --git a/tests/application/test_requests.py b/tests/application/test_requests.py index 1e9ba5a7..e123a30b 100644 --- a/tests/application/test_requests.py +++ b/tests/application/test_requests.py @@ -51,7 +51,7 @@ async def test_zigpy_request(device, make_application): app, znp_server = make_application(device) await app.startup(auto_form=False) - TSN = 7 + TSN = 1 device = app.add_initialized_device(ieee=t.EUI64(range(8)), nwk=0xAABB) @@ -111,7 +111,7 @@ async def test_zigpy_request_failure(device, make_application, mocker): app, znp_server = make_application(device) await app.startup(auto_form=False) - TSN = 7 + TSN = 1 device = app.add_initialized_device(ieee=t.EUI64(range(8)), nwk=0xAABB) @@ -456,7 +456,7 @@ async def inner(): @pytest.mark.parametrize("device", [FormedLaunchpadCC26X2R1]) async def test_request_recovery_route_rediscovery_zdo(device, make_application, mocker): - TSN = 7 + TSN = 1 app, znp_server = make_application(server_cls=device)