Skip to content

Commit

Permalink
Fix startup broken by #577 (#578)
Browse files Browse the repository at this point in the history
* Include missing calls to `write_config` and `register_endpoints`

* Extend unit tests to ensure config is written and endpoints are added
  • Loading branch information
puddly authored Aug 30, 2023
1 parent 21cd029 commit 4e8ad8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bellows/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import bellows
from bellows.config import (
CONF_EZSP_CONFIG,
CONF_EZSP_POLICIES,
CONF_PARAM_MAX_WATCHDOG_FAILURES,
CONF_USE_THREAD,
Expand Down Expand Up @@ -142,6 +143,8 @@ async def connect(self) -> None:
ezsp.close()
raise

# Writing config is required here because network info can't be loaded otherwise
await ezsp.write_config(self.config[CONF_EZSP_CONFIG])
self._ezsp = ezsp

async def _ensure_network_running(self) -> bool:
Expand Down Expand Up @@ -169,6 +172,7 @@ async def _ensure_network_running(self) -> bool:
async def start_network(self):
ezsp = self._ezsp

await self.register_endpoints()
await self._ensure_network_running()

if await repairs.fix_invalid_tclk_partner_ieee(ezsp):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def ezsp_mock(ieee):
mock_ezsp.readCounters = AsyncMock(return_value=[[0] * 10])
mock_ezsp.readAndClearCounters = AsyncMock(return_value=[[0] * 10])
mock_ezsp.setPolicy = AsyncMock(return_value=[0])
mock_ezsp.addEndpoint = AsyncMock(return_value=[t.EmberStatus.SUCCESS])
mock_ezsp.get_board_info = AsyncMock(
return_value=("Mock Manufacturer", "Mock board", "Mock version")
)
Expand Down Expand Up @@ -220,6 +221,9 @@ def form_network():

with p1, p2 as multicast_mock:
await app.startup(auto_form=auto_form)

assert ezsp_mock.write_config.call_count == 1
assert ezsp_mock.addEndpoint.call_count >= 2
assert multicast_mock.await_count == 1


Expand Down

0 comments on commit 4e8ad8c

Please sign in to comment.