* Refactor handling of exposed entities for cloud Alexa * Tweak WS API * Validate assistant parameter * Address some review comments * Refactor handling of exposed entities for cloud Google * Raise when attempting to expose an unknown entity * Add tests * Adjust cloud tests * Allow getting expose new entities flag * Test Alexa migration * Test Google migration * Add WS command cloud/google_assistant/entities/get * Fix return value * Update typing * Address review comments * Rename async_get_exposed_entities to async_get_assistant_settings
29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""Tests for the cloud component."""
|
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
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."""
|
|
assert await async_setup_component(hass, cloud.DOMAIN, {"cloud": config or {}})
|
|
cloud_inst = 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
|