Skip to content

Commit e67e3b0

Browse files
authored
Merge pull request #210 from puddly/rc
0.19.1 Release
2 parents 135346b + a07aad4 commit e67e3b0

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

tests/test_application.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ def new_api(*args):
180180
assert app.version is sentinel.version
181181

182182

183+
async def test_connect_failure(app):
184+
with patch.object(application, "Deconz") as api_mock:
185+
api = api_mock.return_value = MagicMock()
186+
api.connect = AsyncMock()
187+
api.version = AsyncMock(side_effect=RuntimeError("Broken"))
188+
189+
app._api = None
190+
191+
with pytest.raises(RuntimeError):
192+
await app.connect()
193+
194+
assert app._api is None
195+
api.connect.assert_called_once()
196+
api.version.assert_called_once()
197+
api.close.assert_called_once()
198+
199+
183200
async def test_disconnect(app):
184201
reset_watchdog_task = app._reset_watchdog_task = MagicMock()
185202
api_close = app._api.close = MagicMock()

zigpy_deconz/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
# coding: utf-8
44
MAJOR_VERSION = 0
55
MINOR_VERSION = 19
6-
PATCH_VERSION = "0"
6+
PATCH_VERSION = "1"
77
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
88
__version__ = f"{__short_version__}.{PATCH_VERSION}"

zigpy_deconz/zigbee/application.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,14 @@ async def _reset_watchdog(self):
7676

7777
async def connect(self):
7878
api = Deconz(self, self._config[zigpy.config.CONF_DEVICE])
79-
await api.connect()
80-
self.version = await api.version()
79+
80+
try:
81+
await api.connect()
82+
self.version = await api.version()
83+
except Exception:
84+
api.close()
85+
raise
86+
8187
self._api = api
8288
self._written_endpoints.clear()
8389

0 commit comments

Comments
 (0)