Rename async_process_integration_platform to async_process_integration_platform_for_component (#70217)

This commit is contained in:
J. Nick Koston 2022-04-17 20:59:31 -10:00 committed by GitHub
parent a9a5645255
commit 026e1635cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -25,7 +25,7 @@ class IntegrationPlatform:
seen_components: set[str] seen_components: set[str]
async def _async_process_single_integration_platform( async def _async_process_single_integration_platform_component(
hass: HomeAssistant, component_name: str, integration_platform: IntegrationPlatform hass: HomeAssistant, component_name: str, integration_platform: IntegrationPlatform
) -> None: ) -> None:
"""Process a single integration platform.""" """Process a single integration platform."""
@ -55,10 +55,10 @@ async def _async_process_single_integration_platform(
) )
async def async_process_integration_platform( async def async_process_integration_platform_for_component(
hass: HomeAssistant, component_name: str hass: HomeAssistant, component_name: str
) -> None: ) -> None:
"""Process integration platforms on demand. """Process integration platforms on demand for a component.
This function will load the integration platforms This function will load the integration platforms
for an integration instead of waiting for the EVENT_COMPONENT_LOADED for an integration instead of waiting for the EVENT_COMPONENT_LOADED
@ -77,7 +77,7 @@ async def async_process_integration_platform(
] ]
await asyncio.gather( await asyncio.gather(
*[ *[
_async_process_single_integration_platform( _async_process_single_integration_platform_component(
hass, component_name, integration_platform hass, component_name, integration_platform
) )
for integration_platform in integration_platforms for integration_platform in integration_platforms
@ -100,7 +100,7 @@ async def async_process_integration_platforms(
"""Handle a new component loaded.""" """Handle a new component loaded."""
comp = event.data[ATTR_COMPONENT] comp = event.data[ATTR_COMPONENT]
if "." not in comp: if "." not in comp:
await async_process_integration_platform(hass, comp) await async_process_integration_platform_for_component(hass, comp)
hass.bus.async_listen(EVENT_COMPONENT_LOADED, _async_component_loaded) hass.bus.async_listen(EVENT_COMPONENT_LOADED, _async_component_loaded)
@ -114,7 +114,7 @@ async def async_process_integration_platforms(
): ):
await asyncio.gather( await asyncio.gather(
*[ *[
_async_process_single_integration_platform( _async_process_single_integration_platform_component(
hass, comp, integration_platform hass, comp, integration_platform
) )
for comp in top_level_components for comp in top_level_components

View file

@ -2,7 +2,7 @@
from unittest.mock import Mock from unittest.mock import Mock
from homeassistant.helpers.integration_platform import ( from homeassistant.helpers.integration_platform import (
async_process_integration_platform, async_process_integration_platform_for_component,
) )
from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED
@ -40,7 +40,7 @@ async def test_process_integration_platforms(hass):
assert processed[1][1] == event_platform assert processed[1][1] == event_platform
# Verify we only process the platform once if we call it manually # Verify we only process the platform once if we call it manually
await hass.helpers.integration_platform.async_process_integration_platform( await hass.helpers.integration_platform.async_process_integration_platform_for_component(
hass, "event" hass, "event"
) )
assert len(processed) == 2 assert len(processed) == 2
@ -48,6 +48,6 @@ async def test_process_integration_platforms(hass):
async def test_process_integration_platforms_none_loaded(hass): async def test_process_integration_platforms_none_loaded(hass):
"""Test processing integrations with none loaded.""" """Test processing integrations with none loaded."""
# Verify we can call async_process_integration_platform # Verify we can call async_process_integration_platform_for_component
# when there are none loaded and it does not throw # when there are none loaded and it does not throw
await async_process_integration_platform(hass, "any") await async_process_integration_platform_for_component(hass, "any")