Fix homematicip_cloud tests that have uncaught exceptions (#33371)

This commit is contained in:
SukramJ authored and GitHub committed 2020-03-28 21:01:53 -07:00
1 parent 42cb5a5239
commit 3c2df7f8f2
5 files changed
+38 -24

No files matched your search

@@ -39,7 +39,12 @@ async def test_config_with_accesspoint_passed_to_config_entry(
# no acccesspoint exists
assert not hass.data.get(HMIPC_DOMAIN)
assert await async_setup_component(hass, HMIPC_DOMAIN, {HMIPC_DOMAIN: entry_config})
with patch(
"homeassistant.components.homematicip_cloud.hap.HomematicipHAP.async_connect",
):
assert await async_setup_component(
hass, HMIPC_DOMAIN, {HMIPC_DOMAIN: entry_config}
)
# config_entry created for access point
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
@@ -77,7 +82,13 @@ async def test_config_already_registered_not_passed_to_config_entry(
CONF_AUTHTOKEN: "123",
CONF_NAME: "name",
}
assert await async_setup_component(hass, HMIPC_DOMAIN, {HMIPC_DOMAIN: entry_config})
with patch(
"homeassistant.components.homematicip_cloud.hap.HomematicipHAP.async_connect",
):
assert await async_setup_component(
hass, HMIPC_DOMAIN, {HMIPC_DOMAIN: entry_config}
)
# no new config_entry created / still one config_entry
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
@@ -107,16 +118,14 @@ async def test_load_entry_fails_due_to_connection_error(
assert hmip_config_entry.state == ENTRY_STATE_SETUP_RETRY
async def test_load_entry_fails_due_to_generic_exception(
hass, hmip_config_entry, simple_mock_home
):
async def test_load_entry_fails_due_to_generic_exception(hass, hmip_config_entry):
"""Test load entry fails due to generic exception."""
hmip_config_entry.add_to_hass(hass)
with patch(
"homeassistant.components.homematicip_cloud.hap.AsyncHome.get_current_state",
side_effect=Exception,
):
), patch("homematicip.aio.connection.AsyncConnection.init",):
assert await async_setup_component(hass, HMIPC_DOMAIN, {})
assert hass.data[HMIPC_DOMAIN][hmip_config_entry.unique_id]