2018-02-09 08:11:47 +01:00
|
|
|
"""Tests for the cloud component."""
|
2019-06-21 02:17:21 -07:00
|
|
|
|
2021-01-01 22:31:56 +01:00
|
|
|
from unittest.mock import AsyncMock, patch
|
|
|
|
|
2018-09-20 23:46:51 +02:00
|
|
|
from homeassistant.components import cloud
|
2018-11-20 23:23:07 +01:00
|
|
|
from homeassistant.components.cloud import const
|
2019-12-08 18:01:12 +01:00
|
|
|
from homeassistant.setup import async_setup_component
|
2018-09-20 23:46:51 +02:00
|
|
|
|
|
|
|
|
2019-06-21 02:17:21 -07:00
|
|
|
async def mock_cloud(hass, config=None):
|
2018-09-20 23:46:51 +02:00
|
|
|
"""Mock cloud."""
|
2019-07-31 12:25:30 -07:00
|
|
|
assert await async_setup_component(hass, cloud.DOMAIN, {"cloud": config or {}})
|
|
|
|
cloud_inst = hass.data["cloud"]
|
2020-04-30 16:31:00 -07:00
|
|
|
with patch("hass_nabucasa.Cloud.run_executor", AsyncMock(return_value=None)):
|
2019-06-21 02:17:21 -07:00
|
|
|
await cloud_inst.start()
|
2018-09-20 23:46:51 +02:00
|
|
|
|
|
|
|
|
|
|
|
def mock_cloud_prefs(hass, prefs={}):
|
|
|
|
"""Fixture for cloud component."""
|
|
|
|
prefs_to_set = {
|
2018-11-20 23:23:07 +01:00
|
|
|
const.PREF_ENABLE_ALEXA: True,
|
|
|
|
const.PREF_ENABLE_GOOGLE: True,
|
2019-04-19 14:50:21 -07:00
|
|
|
const.PREF_GOOGLE_SECURE_DEVICES_PIN: None,
|
2018-09-20 23:46:51 +02:00
|
|
|
}
|
|
|
|
prefs_to_set.update(prefs)
|
2019-03-11 20:21:20 +01:00
|
|
|
hass.data[cloud.DOMAIN].client._prefs._prefs = prefs_to_set
|
2019-10-13 14:16:27 -07:00
|
|
|
return hass.data[cloud.DOMAIN].client._prefs
|