Skip to content

Commit

Permalink
Merge pull request #210 from puddly/rc
Browse files Browse the repository at this point in the history
0.19.1 Release
  • Loading branch information
puddly authored Nov 7, 2022
2 parents 135346b + a07aad4 commit e67e3b0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
17 changes: 17 additions & 0 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,23 @@ def new_api(*args):
assert app.version is sentinel.version


async def test_connect_failure(app):
with patch.object(application, "Deconz") as api_mock:
api = api_mock.return_value = MagicMock()
api.connect = AsyncMock()
api.version = AsyncMock(side_effect=RuntimeError("Broken"))

app._api = None

with pytest.raises(RuntimeError):
await app.connect()

assert app._api is None
api.connect.assert_called_once()
api.version.assert_called_once()
api.close.assert_called_once()


async def test_disconnect(app):
reset_watchdog_task = app._reset_watchdog_task = MagicMock()
api_close = app._api.close = MagicMock()
Expand Down
2 changes: 1 addition & 1 deletion zigpy_deconz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# coding: utf-8
MAJOR_VERSION = 0
MINOR_VERSION = 19
PATCH_VERSION = "0"
PATCH_VERSION = "1"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
10 changes: 8 additions & 2 deletions zigpy_deconz/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,14 @@ async def _reset_watchdog(self):

async def connect(self):
api = Deconz(self, self._config[zigpy.config.CONF_DEVICE])
await api.connect()
self.version = await api.version()

try:
await api.connect()
self.version = await api.version()
except Exception:
api.close()
raise

self._api = api
self._written_endpoints.clear()

Expand Down

0 comments on commit e67e3b0

Please sign in to comment.