From ab060b86d1597432a9bd35b980180375315660a0 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 21 Sep 2023 17:06:41 +0200 Subject: [PATCH] Remove async_process_integration_platform_for_component (#100680) --- homeassistant/helpers/integration_platform.py | 19 +++---------------- tests/helpers/test_integration_platform.py | 12 ------------ 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/homeassistant/helpers/integration_platform.py b/homeassistant/helpers/integration_platform.py index ddaede44962..0a9a6efd525 100644 --- a/homeassistant/helpers/integration_platform.py +++ b/homeassistant/helpers/integration_platform.py @@ -65,23 +65,10 @@ async def _async_process_single_integration_platform_component( ) -async def async_process_integration_platform_for_component( +async def _async_process_integration_platform_for_component( hass: HomeAssistant, component_name: str ) -> None: - """Process integration platforms on demand for a component. - - This function will load the integration platforms - for an integration instead of waiting for the EVENT_COMPONENT_LOADED - event to be fired for the integration. - - When the integration will create entities before - it has finished setting up; call this function to ensure - that the integration platforms are loaded before the entities - are created. - """ - if DATA_INTEGRATION_PLATFORMS not in hass.data: - # There are no integration platforms loaded yet - return + """Process integration platforms for a component.""" integration_platforms: list[IntegrationPlatform] = hass.data[ DATA_INTEGRATION_PLATFORMS ] @@ -116,7 +103,7 @@ async def async_process_integration_platforms( async def _async_component_loaded(event: Event) -> None: """Handle a new component loaded.""" - await async_process_integration_platform_for_component( + await _async_process_integration_platform_for_component( hass, event.data[ATTR_COMPONENT] ) diff --git a/tests/helpers/test_integration_platform.py b/tests/helpers/test_integration_platform.py index 2dfc0742e26..ed6edcc3690 100644 --- a/tests/helpers/test_integration_platform.py +++ b/tests/helpers/test_integration_platform.py @@ -5,7 +5,6 @@ import pytest from homeassistant.core import HomeAssistant from homeassistant.helpers.integration_platform import ( - async_process_integration_platform_for_component, async_process_integration_platforms, ) from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED @@ -43,17 +42,6 @@ async def test_process_integration_platforms(hass: HomeAssistant) -> None: assert processed[1][0] == "event" assert processed[1][1] == event_platform - # Verify we only process the platform once if we call it manually - await async_process_integration_platform_for_component(hass, "event") - assert len(processed) == 2 - - -async def test_process_integration_platforms_none_loaded(hass: HomeAssistant) -> None: - """Test processing integrations with none loaded.""" - # Verify we can call async_process_integration_platform_for_component - # when there are none loaded and it does not throw - await async_process_integration_platform_for_component(hass, "any") - async def test_broken_integration( hass: HomeAssistant, caplog: pytest.LogCaptureFixture