Add a guard when there are no integration platforms loaded (#70182)
This commit is contained in:
parent
b74986f9c3
commit
b4ef150339
2 changed files with 13 additions and 0 deletions
|
@ -69,6 +69,9 @@ async def async_process_integration_platform(
|
|||
that the integration platforms are loaded before the entities
|
||||
are created.
|
||||
"""
|
||||
if DATA_INTEGRATION_PLATFORMS not in hass.data:
|
||||
# There are no integraton platforms loaded yet
|
||||
return
|
||||
integration_platforms: list[IntegrationPlatform] = hass.data[
|
||||
DATA_INTEGRATION_PLATFORMS
|
||||
]
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
"""Test integration platform helpers."""
|
||||
from unittest.mock import Mock
|
||||
|
||||
from homeassistant.helpers.integration_platform import (
|
||||
async_process_integration_platform,
|
||||
)
|
||||
from homeassistant.setup import ATTR_COMPONENT, EVENT_COMPONENT_LOADED
|
||||
|
||||
from tests.common import mock_platform
|
||||
|
@ -41,3 +44,10 @@ async def test_process_integration_platforms(hass):
|
|||
hass, "event"
|
||||
)
|
||||
assert len(processed) == 2
|
||||
|
||||
|
||||
async def test_process_integration_platforms_none_loaded(hass):
|
||||
"""Test processing integrations with none loaded."""
|
||||
# Verify we can call async_process_integration_platform
|
||||
# when there are none loaded and it does not throw
|
||||
await async_process_integration_platform(hass, "any")
|
||||
|
|
Loading…
Add table
Reference in a new issue