Remove async_process_integration_platform_for_component (#100680)

This commit is contained in:
Erik Montnemery 2023-09-21 17:06:41 +02:00 committed by GitHub
parent 1c7b3cb2d5
commit ab060b86d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 28 deletions

View file

@ -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]
)

View file

@ -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