Add test for adding a device to HomematicIP Cloud (#31224)

* Add test for adding a hmip device

* refactor get_mock_hap to use config_entry setup

* remove unused parameters
This commit is contained in:
SukramJ authored and Martin Hjelmare committed 2020-01-28 08:44:30 +01:00
1 parent 9d8b4de09c
commit ec2d378a19
3 files changed
+66 -22

No files matched your search

+3 -12
View File
@@ -17,13 +17,11 @@ from homeassistant.components.homematicip_cloud.hap import (
HomematicipAuth,
HomematicipHAP,
)
from homeassistant.config_entries import ENTRY_STATE_LOADED, ENTRY_STATE_NOT_LOADED
from homeassistant.config_entries import ENTRY_STATE_NOT_LOADED
from homeassistant.exceptions import ConfigEntryNotReady
from .helper import HAPID, HAPPIN
from tests.common import MockConfigEntry
async def test_auth_setup(hass):
"""Test auth setup for client registration."""
@@ -72,7 +70,7 @@ async def test_auth_auth_check_and_register_with_exception(hass):
assert await hmip_auth.async_register() is False
async def test_hap_setup_works(aioclient_mock):
async def test_hap_setup_works():
"""Test a successful setup of a accesspoint."""
hass = Mock()
entry = Mock()
@@ -109,15 +107,8 @@ async def test_hap_setup_connection_error():
assert not hass.config_entries.flow.async_init.mock_calls
async def test_hap_reset_unloads_entry_if_setup(hass, default_mock_hap, hmip_config):
async def test_hap_reset_unloads_entry_if_setup(hass, default_mock_hap):
"""Test calling reset while the entry has been setup."""
MockConfigEntry(
domain=HMIPC_DOMAIN,
unique_id=HAPID,
data=hmip_config[HMIPC_DOMAIN][0],
state=ENTRY_STATE_LOADED,
).add_to_hass(hass)
assert hass.data[HMIPC_DOMAIN][HAPID] == default_mock_hap
config_entries = hass.config_entries.async_entries(HMIPC_DOMAIN)
assert len(config_entries) == 1