From 3bfdba50d93af15a332abc60f800ea34b613baae Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 24 Jan 2023 23:01:51 -1000 Subject: [PATCH] Migrate homematicip_cloud to use async_forward_entry_setups (#86563) * Migrate homematicip_cloud to use async_forward_entry_setups Replaces deprecated async_setup_platforms with async_forward_entry_setups * adapt test, this test should be rewritten --- homeassistant/components/homematicip_cloud/hap.py | 4 +++- tests/components/homematicip_cloud/test_hap.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/homematicip_cloud/hap.py b/homeassistant/components/homematicip_cloud/hap.py index 7ba30372451..cc4414c9069 100644 --- a/homeassistant/components/homematicip_cloud/hap.py +++ b/homeassistant/components/homematicip_cloud/hap.py @@ -107,7 +107,9 @@ class HomematicipHAP: "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 diff --git a/tests/components/homematicip_cloud/test_hap.py b/tests/components/homematicip_cloud/test_hap.py index a8b3229e8db..2d7d793f54e 100644 --- a/tests/components/homematicip_cloud/test_hap.py +++ b/tests/components/homematicip_cloud/test_hap.py @@ -23,6 +23,8 @@ 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.""" @@ -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():