mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
Migrate integration_platform helper to use async_get_integrations (#89303)
* Migrate integration_platform helper to use async_get_integrations We were fetching integrations inside the gather one at a time. This is inefficent. * cleanup * cleanup * add task name * small tweaks * gather only if we have tasks
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
"""Test integration platform helpers."""
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.integration_platform import (
|
||||
async_process_integration_platform_for_component,
|
||||
@@ -51,3 +53,27 @@ async def test_process_integration_platforms_none_loaded(hass: HomeAssistant) ->
|
||||
# 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
|
||||
) -> None:
|
||||
"""Test handling an integration with a broken or missing manifest."""
|
||||
Mock()
|
||||
hass.config.components.add("loaded")
|
||||
|
||||
event_platform = Mock()
|
||||
mock_platform(hass, "event.platform_to_check", event_platform)
|
||||
|
||||
processed = []
|
||||
|
||||
async def _process_platform(hass, domain, platform):
|
||||
"""Process platform."""
|
||||
processed.append((domain, platform))
|
||||
|
||||
await async_process_integration_platforms(
|
||||
hass, "platform_to_check", _process_platform
|
||||
)
|
||||
|
||||
assert len(processed) == 0
|
||||
assert "Error importing integration loaded for platform_to_check" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user