Skip to content

Commit

Permalink
Fix tests broken by zigpy update (#246)
Browse files Browse the repository at this point in the history
* 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"
  • Loading branch information
TheJulianJES authored Apr 11, 2024
1 parent 7171c6a commit b658bc1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 3 additions & 5 deletions tests/application/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions tests/application/test_joining.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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",
),
Expand Down
6 changes: 3 additions & 3 deletions tests/application/test_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit b658bc1

Please sign in to comment.