From f3a9756f819bcee792166704c28dc6e288ede41c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 5 Mar 2024 21:16:42 -1000 Subject: [PATCH] Avoid waiting for integration platforms in the parent integration (#112467) --- homeassistant/components/backup/manager.py | 2 +- .../components/energy/websocket_api.py | 4 +- homeassistant/components/hardware/hardware.py | 4 +- .../silabs_multiprotocol_addon.py | 5 ++- .../components/repairs/issue_handler.py | 4 +- homeassistant/helpers/integration_platform.py | 31 +++++++++++++ .../accuweather/test_system_health.py | 2 + tests/components/airly/test_system_health.py | 2 + tests/components/alexa/test_init.py | 1 + .../assist_pipeline/test_logbook.py | 1 + tests/components/automation/test_init.py | 1 + tests/components/automation/test_logbook.py | 1 + tests/components/backup/test_manager.py | 2 + tests/components/deconz/test_logbook.py | 2 + tests/components/energy/test_websocket_api.py | 3 ++ tests/components/gios/test_system_health.py | 2 + .../google_assistant/test_logbook.py | 1 + tests/components/group/test_init.py | 1 + tests/components/hassio/test_system_health.py | 2 + tests/components/homekit/test_init.py | 1 + tests/components/ipma/test_system_health.py | 1 + tests/components/isy994/test_system_health.py | 2 + .../components/nextdns/test_system_health.py | 2 + .../components/raspberry_pi/test_hardware.py | 2 + tests/components/script/test_init.py | 1 + tests/components/shelly/test_logbook.py | 2 + tests/components/zha/test_logbook.py | 3 ++ tests/components/zwave_js/test_logbook.py | 2 + tests/helpers/test_integration_platform.py | 44 +++++++++++++++++++ 29 files changed, 126 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/backup/manager.py b/homeassistant/components/backup/manager.py index 4c06f2171b6..ba5d8c8733c 100644 --- a/homeassistant/components/backup/manager.py +++ b/homeassistant/components/backup/manager.py @@ -125,7 +125,7 @@ class BackupManager: async def load_platforms(self) -> None: """Load backup platforms.""" await integration_platform.async_process_integration_platforms( - self.hass, DOMAIN, self._add_platform + self.hass, DOMAIN, self._add_platform, wait_for_platforms=True ) LOGGER.debug("Loaded %s platforms", len(self.platforms)) self.loaded_platforms = True diff --git a/homeassistant/components/energy/websocket_api.py b/homeassistant/components/energy/websocket_api.py index 5d9cd81013d..73aa8330bfe 100644 --- a/homeassistant/components/energy/websocket_api.py +++ b/homeassistant/components/energy/websocket_api.py @@ -71,7 +71,9 @@ async def async_get_energy_platforms( platforms[domain] = cast(EnergyPlatform, platform).async_get_solar_forecast - await async_process_integration_platforms(hass, DOMAIN, _process_energy_platform) + await async_process_integration_platforms( + hass, DOMAIN, _process_energy_platform, wait_for_platforms=True + ) return platforms diff --git a/homeassistant/components/hardware/hardware.py b/homeassistant/components/hardware/hardware.py index d44a232c232..800f15137c6 100644 --- a/homeassistant/components/hardware/hardware.py +++ b/homeassistant/components/hardware/hardware.py @@ -15,7 +15,9 @@ async def async_process_hardware_platforms(hass: HomeAssistant) -> None: """Start processing hardware platforms.""" hass.data[DOMAIN]["hardware_platform"] = {} - await async_process_integration_platforms(hass, DOMAIN, _register_hardware_platform) + await async_process_integration_platforms( + hass, DOMAIN, _register_hardware_platform, wait_for_platforms=True + ) @callback diff --git a/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py b/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py index 2a2d617c5b4..5a1cf1d5421 100644 --- a/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py +++ b/homeassistant/components/homeassistant_hardware/silabs_multiprotocol_addon.py @@ -143,7 +143,10 @@ class MultiprotocolAddonManager(WaitingAddonManager): async def async_setup(self) -> None: """Set up the manager.""" await async_process_integration_platforms( - self._hass, "silabs_multiprotocol", self._register_multipan_platform + self._hass, + "silabs_multiprotocol", + self._register_multipan_platform, + wait_for_platforms=True, ) await self.async_load() diff --git a/homeassistant/components/repairs/issue_handler.py b/homeassistant/components/repairs/issue_handler.py index f2ce3bac84e..be7a6310464 100644 --- a/homeassistant/components/repairs/issue_handler.py +++ b/homeassistant/components/repairs/issue_handler.py @@ -102,7 +102,9 @@ async def async_process_repairs_platforms(hass: HomeAssistant) -> None: """Start processing repairs platforms.""" hass.data[DOMAIN]["platforms"] = {} - await async_process_integration_platforms(hass, DOMAIN, _register_repairs_platform) + await async_process_integration_platforms( + hass, DOMAIN, _register_repairs_platform, wait_for_platforms=True + ) @callback diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index ef9c97504ae..7debae6072f 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -157,6 +157,7 @@ async def async_process_integration_platforms( platform_name: str, # Any = platform. process_platform: Callable[[HomeAssistant, str, Any], Awaitable[None] | None], + wait_for_platforms: bool = False, ) -> None: """Process a specific platform for all current and future loaded integrations.""" if DATA_INTEGRATION_PLATFORMS not in hass.data: @@ -194,6 +195,36 @@ async def async_process_integration_platforms( if not top_level_components: return + # We create a task here for two reasons: + # + # 1. We want the integration that provides the integration platform to + # not be delayed by waiting on each individual platform to be processed + # since the import or the integration platforms themselves may have to + # schedule I/O or executor jobs. + # + # 2. We want the behavior to be the same as if the integration that has + # the integration platform is loaded after the platform is processed. + # + # We use hass.async_create_task instead of asyncio.create_task because + # we want to make sure that startup waits for the task to complete. + # + future = hass.async_create_task( + _async_process_integration_platforms( + hass, platform_name, top_level_components.copy(), process_job + ), + eager_start=True, + ) + if wait_for_platforms: + await future + + +async def _async_process_integration_platforms( + hass: HomeAssistant, + platform_name: str, + top_level_components: set[str], + process_job: HassJob, +) -> None: + """Process integration platforms for a component.""" integrations = await async_get_integrations(hass, top_level_components) loaded_integrations: list[Integration] = [ integration diff --git a/tests/components/accuweather/test_system_health.py b/tests/components/accuweather/test_system_health.py index b7acc318883..34f5b761ccb 100644 --- a/tests/components/accuweather/test_system_health.py +++ b/tests/components/accuweather/test_system_health.py @@ -19,6 +19,7 @@ async def test_accuweather_system_health( aioclient_mock.get("https://dataservice.accuweather.com/", text="") hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() hass.data[DOMAIN] = {} hass.data[DOMAIN]["0123xyz"] = {} @@ -43,6 +44,7 @@ async def test_accuweather_system_health_fail( aioclient_mock.get("https://dataservice.accuweather.com/", exc=ClientError) hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() hass.data[DOMAIN] = {} hass.data[DOMAIN]["0123xyz"] = {} diff --git a/tests/components/airly/test_system_health.py b/tests/components/airly/test_system_health.py index 38f4378a2e3..fa26f6ccd0c 100644 --- a/tests/components/airly/test_system_health.py +++ b/tests/components/airly/test_system_health.py @@ -19,6 +19,7 @@ async def test_airly_system_health( aioclient_mock.get("https://airapi.airly.eu/v2/", text="") hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() hass.data[DOMAIN] = {} hass.data[DOMAIN]["0123xyz"] = Mock( @@ -47,6 +48,7 @@ async def test_airly_system_health_fail( aioclient_mock.get("https://airapi.airly.eu/v2/", exc=ClientError) hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() hass.data[DOMAIN] = {} hass.data[DOMAIN]["0123xyz"] = Mock( diff --git a/tests/components/alexa/test_init.py b/tests/components/alexa/test_init.py index 279fbfc4cef..3ddf33776bb 100644 --- a/tests/components/alexa/test_init.py +++ b/tests/components/alexa/test_init.py @@ -11,6 +11,7 @@ async def test_humanify_alexa_event(hass: HomeAssistant) -> None: hass.config.components.add("recorder") await async_setup_component(hass, "alexa", {}) await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() hass.states.async_set("light.kitchen", "on", {"friendly_name": "Kitchen Light"}) results = mock_humanify( diff --git a/tests/components/assist_pipeline/test_logbook.py b/tests/components/assist_pipeline/test_logbook.py index c1e0633ed57..aaa36b730fe 100644 --- a/tests/components/assist_pipeline/test_logbook.py +++ b/tests/components/assist_pipeline/test_logbook.py @@ -15,6 +15,7 @@ async def test_recording_event( """Test recording event.""" hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() entry = MockConfigEntry() entry.add_to_hass(hass) diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index 462f748c15e..e613a997939 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -1862,6 +1862,7 @@ async def test_logbook_humanify_automation_triggered_event(hass: HomeAssistant) hass.config.components.add("recorder") await async_setup_component(hass, automation.DOMAIN, {}) await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() event1, event2 = mock_humanify( hass, diff --git a/tests/components/automation/test_logbook.py b/tests/components/automation/test_logbook.py index 802977a63be..7063f2bfb3e 100644 --- a/tests/components/automation/test_logbook.py +++ b/tests/components/automation/test_logbook.py @@ -11,6 +11,7 @@ async def test_humanify_automation_trigger_event(hass: HomeAssistant) -> None: hass.config.components.add("recorder") assert await async_setup_component(hass, "automation", {}) assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() context = Context() event1, event2 = mock_humanify( diff --git a/tests/components/backup/test_manager.py b/tests/components/backup/test_manager.py index f7ecab0efa1..129607e7304 100644 --- a/tests/components/backup/test_manager.py +++ b/tests/components/backup/test_manager.py @@ -199,6 +199,7 @@ async def test_loading_platforms( ), ) await manager.load_platforms() + await hass.async_block_till_done() assert manager.loaded_platforms assert len(manager.platforms) == 1 @@ -218,6 +219,7 @@ async def test_not_loading_bad_platforms( await _setup_mock_domain(hass) await manager.load_platforms() + await hass.async_block_till_done() assert manager.loaded_platforms assert len(manager.platforms) == 0 diff --git a/tests/components/deconz/test_logbook.py b/tests/components/deconz/test_logbook.py index 4d2043923bd..83f2e463992 100644 --- a/tests/components/deconz/test_logbook.py +++ b/tests/components/deconz/test_logbook.py @@ -74,6 +74,7 @@ async def test_humanifying_deconz_alarm_event( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() events = mock_humanify( hass, @@ -183,6 +184,7 @@ async def test_humanifying_deconz_event( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() events = mock_humanify( hass, diff --git a/tests/components/energy/test_websocket_api.py b/tests/components/energy/test_websocket_api.py index f953d0e3a03..f136c37b544 100644 --- a/tests/components/energy/test_websocket_api.py +++ b/tests/components/energy/test_websocket_api.py @@ -89,6 +89,7 @@ async def test_save_preferences( mock_energy_platform, ) -> None: """Test we can save preferences.""" + await hass.async_block_till_done() client = await hass_ws_client(hass) # Test saving default prefs is also valid. @@ -283,6 +284,7 @@ async def test_get_solar_forecast( entry.add_to_hass(hass) manager = await data.async_get_manager(hass) + manager.data = data.EnergyManager.default_preferences() manager.data["energy_sources"].append( { @@ -292,6 +294,7 @@ async def test_get_solar_forecast( } ) client = await hass_ws_client(hass) + await hass.async_block_till_done() await client.send_json({"id": 5, "type": "energy/solar_forecast"}) diff --git a/tests/components/gios/test_system_health.py b/tests/components/gios/test_system_health.py index 00e2fe50dd4..571614ed1de 100644 --- a/tests/components/gios/test_system_health.py +++ b/tests/components/gios/test_system_health.py @@ -21,6 +21,7 @@ async def test_gios_system_health( await integration.async_get_component() hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() info = await get_system_health_info(hass, DOMAIN) @@ -40,6 +41,7 @@ async def test_gios_system_health_fail( await integration.async_get_component() hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() info = await get_system_health_info(hass, DOMAIN) diff --git a/tests/components/google_assistant/test_logbook.py b/tests/components/google_assistant/test_logbook.py index 58b747a6f07..e8132d822e8 100644 --- a/tests/components/google_assistant/test_logbook.py +++ b/tests/components/google_assistant/test_logbook.py @@ -18,6 +18,7 @@ async def test_humanify_command_received(hass: HomeAssistant) -> None: hass.config.components.add("frontend") hass.config.components.add("google_assistant") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() hass.states.async_set( "light.kitchen", "on", {ATTR_FRIENDLY_NAME: "The Kitchen Lights"} diff --git a/tests/components/group/test_init.py b/tests/components/group/test_init.py index a9a2145798b..6dd1ca1a6ed 100644 --- a/tests/components/group/test_init.py +++ b/tests/components/group/test_init.py @@ -759,6 +759,7 @@ async def test_service_group_services_add_remove_entities(hass: HomeAssistant) - assert await async_setup_component(hass, "person", {}) with assert_setup_component(0, "group"): await async_setup_component(hass, "group", {"group": {}}) + await hass.async_block_till_done() assert hass.services.has_service("group", group.SERVICE_SET) diff --git a/tests/components/hassio/test_system_health.py b/tests/components/hassio/test_system_health.py index 715bf3bab91..bce3e5991fb 100644 --- a/tests/components/hassio/test_system_health.py +++ b/tests/components/hassio/test_system_health.py @@ -29,6 +29,7 @@ async def test_hassio_system_health( hass.config.components.add("hassio") assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() hass.data["hassio_info"] = { "channel": "stable", @@ -88,6 +89,7 @@ async def test_hassio_system_health_with_issues( hass.config.components.add("hassio") assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() hass.data["hassio_info"] = {"channel": "stable"} hass.data["hassio_host_info"] = {} diff --git a/tests/components/homekit/test_init.py b/tests/components/homekit/test_init.py index 5a1d42352fe..1f0d9846fd1 100644 --- a/tests/components/homekit/test_init.py +++ b/tests/components/homekit/test_init.py @@ -33,6 +33,7 @@ async def test_humanify_homekit_changed_event( with patch("homeassistant.components.homekit.HomeKit"): assert await async_setup_component(hass, "homekit", {"homekit": {}}) assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() event1, event2 = mock_humanify( hass, diff --git a/tests/components/ipma/test_system_health.py b/tests/components/ipma/test_system_health.py index 665ed193da1..b4cefad80c0 100644 --- a/tests/components/ipma/test_system_health.py +++ b/tests/components/ipma/test_system_health.py @@ -17,6 +17,7 @@ async def test_ipma_system_health( hass.config.components.add("ipma") assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() info = await get_system_health_info(hass, "ipma") diff --git a/tests/components/isy994/test_system_health.py b/tests/components/isy994/test_system_health.py index fdc0c634f8a..fa5bab0025c 100644 --- a/tests/components/isy994/test_system_health.py +++ b/tests/components/isy994/test_system_health.py @@ -27,6 +27,7 @@ async def test_system_health( hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() MockConfigEntry( domain=DOMAIN, @@ -66,6 +67,7 @@ async def test_system_health_failed_connect( hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() MockConfigEntry( domain=DOMAIN, diff --git a/tests/components/nextdns/test_system_health.py b/tests/components/nextdns/test_system_health.py index 14d447947c1..4d4299621e8 100644 --- a/tests/components/nextdns/test_system_health.py +++ b/tests/components/nextdns/test_system_health.py @@ -19,6 +19,7 @@ async def test_nextdns_system_health( aioclient_mock.get(API_ENDPOINT, text="") hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() info = await get_system_health_info(hass, DOMAIN) @@ -36,6 +37,7 @@ async def test_nextdns_system_health_fail( aioclient_mock.get(API_ENDPOINT, exc=ClientError) hass.config.components.add(DOMAIN) assert await async_setup_component(hass, "system_health", {}) + await hass.async_block_till_done() info = await get_system_health_info(hass, DOMAIN) diff --git a/tests/components/raspberry_pi/test_hardware.py b/tests/components/raspberry_pi/test_hardware.py index d41fbf2f5e1..430611d1576 100644 --- a/tests/components/raspberry_pi/test_hardware.py +++ b/tests/components/raspberry_pi/test_hardware.py @@ -18,6 +18,7 @@ async def test_hardware_info( """Test we can get the board info.""" mock_integration(hass, MockModule("hassio")) await async_setup_component(hass, HASSIO_DOMAIN, {}) + await hass.async_block_till_done() # Setup the config entry config_entry = MockConfigEntry( @@ -70,6 +71,7 @@ async def test_hardware_info_fail( """Test async_info raises if os_info is not as expected.""" mock_integration(hass, MockModule("hassio")) await async_setup_component(hass, HASSIO_DOMAIN, {}) + await hass.async_block_till_done() # Setup the config entry config_entry = MockConfigEntry( diff --git a/tests/components/script/test_init.py b/tests/components/script/test_init.py index 2d21dc924dd..5a5c2c4c9ce 100644 --- a/tests/components/script/test_init.py +++ b/tests/components/script/test_init.py @@ -898,6 +898,7 @@ async def test_logbook_humanify_script_started_event(hass: HomeAssistant) -> Non hass.config.components.add("recorder") await async_setup_component(hass, DOMAIN, {}) await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() event1, event2 = mock_humanify( hass, diff --git a/tests/components/shelly/test_logbook.py b/tests/components/shelly/test_logbook.py index 35c0d5a17de..7cf73fd343f 100644 --- a/tests/components/shelly/test_logbook.py +++ b/tests/components/shelly/test_logbook.py @@ -31,6 +31,7 @@ async def test_humanify_shelly_click_event_block_device( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() event1, event2 = mock_humanify( hass, @@ -81,6 +82,7 @@ async def test_humanify_shelly_click_event_rpc_device( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() event1, event2 = mock_humanify( hass, diff --git a/tests/components/zha/test_logbook.py b/tests/components/zha/test_logbook.py index 44495cf0e15..b0d7d7579f3 100644 --- a/tests/components/zha/test_logbook.py +++ b/tests/components/zha/test_logbook.py @@ -84,6 +84,7 @@ async def test_zha_logbook_event_device_with_triggers( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() events = mock_humanify( hass, @@ -162,6 +163,7 @@ async def test_zha_logbook_event_device_no_triggers( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() events = mock_humanify( hass, @@ -246,6 +248,7 @@ async def test_zha_logbook_event_device_no_device( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() events = mock_humanify( hass, diff --git a/tests/components/zwave_js/test_logbook.py b/tests/components/zwave_js/test_logbook.py index 98062612309..c4e601da2fc 100644 --- a/tests/components/zwave_js/test_logbook.py +++ b/tests/components/zwave_js/test_logbook.py @@ -25,6 +25,7 @@ async def test_humanifying_zwave_js_notification_event( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() events = mock_humanify( hass, @@ -108,6 +109,7 @@ async def test_humanifying_zwave_js_value_notification_event( hass.config.components.add("recorder") assert await async_setup_component(hass, "logbook", {}) + await hass.async_block_till_done() events = mock_humanify( hass, diff --git a/tests/helpers/test_integration_platform.py b/tests/helpers/test_integration_platform.py index 9b1919b35a0..70874a7a58c 100644 --- a/tests/helpers/test_integration_platform.py +++ b/tests/helpers/test_integration_platform.py @@ -16,6 +16,44 @@ from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED from tests.common import mock_platform +async def test_process_integration_platforms_with_wait(hass: HomeAssistant) -> None: + """Test processing integrations.""" + loaded_platform = Mock() + mock_platform(hass, "loaded.platform_to_check", loaded_platform) + hass.config.components.add("loaded") + + event_platform = Mock() + mock_platform(hass, "event.platform_to_check", event_platform) + + processed = [] + + async def _process_platform(hass, domain, platform): + """Process platform.""" + processed.append((domain, platform)) + + await async_process_integration_platforms( + hass, "platform_to_check", _process_platform, wait_for_platforms=True + ) + # No block till done here, we want to make sure it waits for the platform + + assert len(processed) == 1 + assert processed[0][0] == "loaded" + assert processed[0][1] == loaded_platform + + hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: "event"}) + await hass.async_block_till_done() + + assert len(processed) == 2 + assert processed[1][0] == "event" + assert processed[1][1] == event_platform + + hass.bus.async_fire(EVENT_COMPONENT_LOADED, {ATTR_COMPONENT: "event"}) + await hass.async_block_till_done() + + # Firing again should not check again + assert len(processed) == 2 + + async def test_process_integration_platforms(hass: HomeAssistant) -> None: """Test processing integrations.""" loaded_platform = Mock() @@ -34,6 +72,7 @@ async def test_process_integration_platforms(hass: HomeAssistant) -> None: await async_process_integration_platforms( hass, "platform_to_check", _process_platform ) + await hass.async_block_till_done() assert len(processed) == 1 assert processed[0][0] == "loaded" @@ -77,6 +116,7 @@ async def test_process_integration_platforms_import_fails( await async_process_integration_platforms( hass, "platform_to_check", _process_platform ) + await hass.async_block_till_done() assert len(processed) == 0 assert "Unexpected error importing platform_to_check for loaded" in caplog.text @@ -115,6 +155,7 @@ async def test_process_integration_platforms_import_fails_after_registered( await async_process_integration_platforms( hass, "platform_to_check", _process_platform ) + await hass.async_block_till_done() assert len(processed) == 1 assert processed[0][0] == "loaded" @@ -166,6 +207,7 @@ async def test_process_integration_platforms_non_compliant( await async_process_integration_platforms( hass, "platform_to_check", process_platform ) + await hass.async_block_till_done() assert len(processed) == 0 assert "Exception in " in caplog.text @@ -204,6 +246,7 @@ async def test_broken_integration( await async_process_integration_platforms( hass, "platform_to_check", _process_platform ) + await hass.async_block_till_done() # This should never actually happen as the component cannot be # in hass.config.components without a loaded manifest @@ -226,5 +269,6 @@ async def test_process_integration_platforms_no_integrations( await async_process_integration_platforms( hass, "platform_to_check", _process_platform ) + await hass.async_block_till_done() assert len(processed) == 0