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