Make assist_pipeline an after dependency of cloud (#92057)

pull/92058/head
Erik Montnemery 2023-04-26 13:45:32 +02:00 committed by GitHub
parent ed737f306b
commit 2750a5c3e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View File

@ -23,6 +23,7 @@ from homeassistant.helpers.collection import (
StorageCollection,
StorageCollectionWebsocket,
)
from homeassistant.helpers.singleton import singleton
from homeassistant.helpers.storage import Store
from homeassistant.util import (
dt as dt_util,
@ -956,7 +957,8 @@ class PipelineRunDebug:
)
async def async_setup_pipeline_store(hass: HomeAssistant) -> None:
@singleton(DOMAIN)
async def async_setup_pipeline_store(hass: HomeAssistant) -> PipelineData:
"""Set up the pipeline storage collection."""
pipeline_store = PipelineStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY)
@ -969,4 +971,4 @@ async def async_setup_pipeline_store(hass: HomeAssistant) -> None:
PIPELINE_FIELDS,
PIPELINE_FIELDS,
).async_setup(hass)
hass.data[DOMAIN] = PipelineData({}, pipeline_store)
return PipelineData({}, pipeline_store)

View File

@ -198,6 +198,9 @@ class CloudLoginView(HomeAssistantView):
cloud = hass.data[DOMAIN]
await cloud.login(data["email"], data["password"])
# Make sure the pipeline store is loaded, needed because assist_pipeline
# is an after dependency of cloud
await assist_pipeline.async_setup_pipeline_store(hass)
if (cloud_pipeline_id := cloud_assist_pipeline(hass)) is None:
if cloud_pipeline := await assist_pipeline.async_create_default_pipeline(
hass, DOMAIN, DOMAIN

View File

@ -1,9 +1,9 @@
{
"domain": "cloud",
"name": "Home Assistant Cloud",
"after_dependencies": ["google_assistant", "alexa"],
"after_dependencies": ["assist_pipeline", "google_assistant", "alexa"],
"codeowners": ["@home-assistant/cloud"],
"dependencies": ["assist_pipeline", "homeassistant", "http", "webhook"],
"dependencies": ["homeassistant", "http", "webhook"],
"documentation": "https://www.home-assistant.io/integrations/cloud",
"integration_type": "system",
"iot_class": "cloud_push",

View File

@ -16,6 +16,7 @@ from homeassistant.components.cloud.const import DOMAIN
from homeassistant.components.google_assistant.helpers import GoogleEntity
from homeassistant.core import HomeAssistant, State
from homeassistant.helpers import entity_registry as er
from homeassistant.setup import async_setup_component
from homeassistant.util.location import LocationInfo
from . import mock_cloud, mock_cloud_prefs
@ -106,6 +107,8 @@ async def test_google_actions_sync_fails(
async def test_login_view(hass: HomeAssistant, cloud_client) -> None:
"""Test logging in when an assist pipeline is available."""
hass.data["cloud"] = MagicMock(login=AsyncMock())
await async_setup_component(hass, "stt", {})
await async_setup_component(hass, "tts", {})
with patch(
"homeassistant.components.cloud.http_api.assist_pipeline.async_get_pipelines",
@ -133,6 +136,8 @@ async def test_login_view(hass: HomeAssistant, cloud_client) -> None:
async def test_login_view_create_pipeline(hass: HomeAssistant, cloud_client) -> None:
"""Test logging in when no assist pipeline is available."""
hass.data["cloud"] = MagicMock(login=AsyncMock())
await async_setup_component(hass, "stt", {})
await async_setup_component(hass, "tts", {})
with patch(
"homeassistant.components.cloud.http_api.assist_pipeline.async_create_default_pipeline",
@ -153,6 +158,8 @@ async def test_login_view_create_pipeline_fail(
) -> None:
"""Test logging in when no assist pipeline is available."""
hass.data["cloud"] = MagicMock(login=AsyncMock())
await async_setup_component(hass, "stt", {})
await async_setup_component(hass, "tts", {})
with patch(
"homeassistant.components.cloud.http_api.assist_pipeline.async_create_default_pipeline",