Skip to content

Commit dd0f983

Browse files
Adminiugadamarco
authored andcommitted
Add ControllerApplication.shutdown() method. (#26)
Goes along with zigpy/zigpy#133
1 parent 011546b commit dd0f983

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/test_application.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,10 @@ def test_handle_reply_unexpected(app):
224224
assert app.handle_message.call_args[0][6] == tsn
225225
assert app.handle_message.call_args[0][7] == mock.sentinel.command_id
226226
assert app.handle_message.call_args[0][8] == mock.sentinel.args
227+
228+
229+
@pytest.mark.asyncio
230+
async def test_shutdown(app):
231+
app._api.close = mock.MagicMock()
232+
await app.shutdown()
233+
assert app._api.close.call_count == 1

zigpy_deconz/zigbee/application.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ async def _reset_watchdog(self):
3535
await self._api.write_parameter(NETWORK_PARAMETER['watchdog_ttl'][0], 3600)
3636
await asyncio.sleep(1200)
3737

38+
async def shutdown(self):
39+
"""Shutdown application."""
40+
self._api.close()
41+
3842
async def startup(self, auto_form=False):
3943
"""Perform a complete application startup"""
4044
r = await self._api.version()

0 commit comments

Comments
 (0)