hass-core/tests/components/cloud/__init__.py
Martin Hjelmare e1f31194f7
Move cloud stt engine to config entry (#99608)
* Migrate cloud stt to config entry

* Update default engine

* Test config flow

* Migrate pipelines with cloud stt engine to new engine id

* Fix test after rebase

* Update and add comment

* Remove cloud specifics from default stt engine

* Refactor cloud assist pipeline

* Fix cloud stt entity_id

* Try to wait for platforms before creating default pipeline

* Clean up import

* Move function in cloud assist pipeline

* Wait for tts platform loaded in stt migration

* Update deprecation dates

* Clean up not used fixture

* Add test for async_update_pipeline

* Define pipeline update interface better

* Remove leftover

* Fix tests

* Change default engine test

* Add test for missing stt entity during login

* Add and update comments

* Update config entry title
2023-12-21 13:39:02 +01:00

34 lines
1.3 KiB
Python

"""Tests for the cloud component."""
from unittest.mock import AsyncMock, patch
from hass_nabucasa import Cloud
from homeassistant.components import cloud
from homeassistant.components.cloud import const, prefs as cloud_prefs
from homeassistant.setup import async_setup_component
async def mock_cloud(hass, config=None):
"""Mock cloud."""
# The homeassistant integration is needed by cloud. It's not in it's requirements
# because it's always setup by bootstrap. Set it up manually in tests.
assert await async_setup_component(hass, "homeassistant", {})
assert await async_setup_component(hass, cloud.DOMAIN, {"cloud": config or {}})
cloud_inst: Cloud = hass.data["cloud"]
with patch("hass_nabucasa.Cloud.run_executor", AsyncMock(return_value=None)):
await cloud_inst.initialize()
def mock_cloud_prefs(hass, prefs={}):
"""Fixture for cloud component."""
prefs_to_set = {
const.PREF_ALEXA_SETTINGS_VERSION: cloud_prefs.ALEXA_SETTINGS_VERSION,
const.PREF_ENABLE_ALEXA: True,
const.PREF_ENABLE_GOOGLE: True,
const.PREF_GOOGLE_SECURE_DEVICES_PIN: None,
const.PREF_GOOGLE_SETTINGS_VERSION: cloud_prefs.GOOGLE_SETTINGS_VERSION,
}
prefs_to_set.update(prefs)
hass.data[cloud.DOMAIN].client._prefs._prefs = prefs_to_set
return hass.data[cloud.DOMAIN].client._prefs