Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Jul 23, 2024
1 parent 7925c6e commit 8967318
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bellows/ezsp/v4/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,5 @@ async def send_broadcast(
return t.sl_Status.from_ember_status(status), sequence

async def set_source_route(self, nwk: t.NWK, relays: list[t.NWK]) -> t.sl_Status:
(res,) = await self._ezsp.setSourceRoute(destination=nwk, relayList=relays)
return t.sl_Status.from_ember_status(res) == t.sl_Status.OK
(res,) = await self.setSourceRoute(destination=nwk, relayList=relays)
return t.sl_Status.from_ember_status(res)
19 changes: 11 additions & 8 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,20 +831,23 @@ async def test_send_packet_unicast_ieee_no_fallback(app, packet, caplog):
assert app._ezsp.send_unicast.call_count == 0


async def test_send_packet_unicast_source_route_ezsp7(make_app, packet):
async def test_send_packet_unicast_source_route(make_app, packet):
app = make_app({zigpy.config.CONF_SOURCE_ROUTING: True})
app._ezsp.ezsp_version = 7
app._ezsp.setSourceRoute = AsyncMock(return_value=(t.EmberStatus.SUCCESS,))
app._ezsp.set_source_route = AsyncMock(return_value=(t.sl_Status.OK,))

packet.source_route = [0x0001, 0x0002]
await _test_send_packet_unicast(
app, packet, options=(t.EmberApsOption.APS_OPTION_RETRY)
app,
packet,
options=(
t.EmberApsOption.APS_OPTION_RETRY
| t.EmberApsOption.APS_OPTION_ENABLE_ADDRESS_DISCOVERY
),
)

assert app._ezsp.setSourceRoute.await_count == 1
app._ezsp.setSourceRoute.assert_called_once_with(
destination=packet.dst.address,
relayList=[0x0001, 0x0002],
app._ezsp.set_source_route.assert_called_once_with(
nwk=packet.dst.address,
relays=[0x0001, 0x0002],
)


Expand Down

0 comments on commit 8967318

Please sign in to comment.