Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate homematicip_cloud to use async_forward_entry_setups #86563

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion homeassistant/components/homematicip_cloud/hap.py
Expand Up @@ -107,7 +107,9 @@ async def async_setup(self, tries: int = 0) -> bool:
"Connected to HomematicIP with HAP %s", self.config_entry.unique_id
)

self.hass.config_entries.async_setup_platforms(self.config_entry, PLATFORMS)
await self.hass.config_entries.async_forward_entry_setups(
self.config_entry, PLATFORMS
)

return True

Expand Down
13 changes: 8 additions & 5 deletions tests/components/homematicip_cloud/test_hap.py
Expand Up @@ -23,6 +23,8 @@

from .helper import HAPID, HAPPIN

from tests.common import MockConfigEntry


async def test_auth_setup(hass):
"""Test auth setup for client registration."""
Expand Down Expand Up @@ -71,18 +73,19 @@ 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():
async def test_hap_setup_works(hass):
"""Test a successful setup of a accesspoint."""
hass = Mock()
entry = Mock()
# This test should not be accessing the integration internals
entry = MockConfigEntry(
domain=HMIPC_DOMAIN,
data={HMIPC_HAPID: "ABC123", HMIPC_AUTHTOKEN: "123", HMIPC_NAME: "hmip"},
)
home = Mock()
entry.data = {HMIPC_HAPID: "ABC123", HMIPC_AUTHTOKEN: "123", HMIPC_NAME: "hmip"}
hap = HomematicipHAP(hass, entry)
with patch.object(hap, "get_hap", return_value=home):
assert await hap.async_setup()

assert hap.home is home
assert len(hass.config_entries.async_setup_platforms.mock_calls) == 1


async def test_hap_setup_connection_error():
Expand Down