Don't directly update config entries (#20877)

* Don't directly update config entries

* Use ConfigEntryNotReady

* Fix tests

* Remove old test

* Lint
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-02-13 20:36:06 -08:00
1 parent 161c368c9d
commit 882f5ed079
11 files changed
+54 -169

No files matched your search

@@ -1,6 +1,9 @@
"""Test HomematicIP Cloud accesspoint."""
from unittest.mock import Mock, patch
import pytest
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.components.homematicip_cloud import hap as hmipc
from homeassistant.components.homematicip_cloud import const, errors
from tests.common import mock_coro, mock_coro_func
@@ -82,9 +85,10 @@ async def test_hap_setup_connection_error():
hmipc.HMIPC_NAME: 'hmip',
}
hap = hmipc.HomematicipHAP(hass, entry)
with patch.object(hap, 'get_hap',
side_effect=errors.HmipcConnectionError):
assert await hap.async_setup() is False
with patch.object(
hap, 'get_hap', side_effect=errors.HmipcConnectionError
), pytest.raises(ConfigEntryNotReady):
await hap.async_setup()
assert len(hass.async_add_job.mock_calls) == 0
assert len(hass.config_entries.flow.async_init.mock_calls) == 0