Skip to content

Commit

Permalink
Remove async_process_integration_platform_for_component (home-assista…
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery committed Sep 21, 2023
1 parent 1c7b3cb commit ab060b8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
19 changes: 3 additions & 16 deletions homeassistant/helpers/integration_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down Expand Up @@ -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]
)

Expand Down
12 changes: 0 additions & 12 deletions tests/helpers/test_integration_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

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
Expand Down Expand Up @@ -43,17 +42,6 @@ async def _process_platform(hass, domain, platform):
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
Expand Down

0 comments on commit ab060b8

Please sign in to comment.