Add option to disable specific integrations (#16757)
* Add option to disable specific integrations * Lint
This commit is contained in:
parent
03de658d4d
commit
092c146eae
10 changed files with 222 additions and 28 deletions
|
@ -6,10 +6,14 @@ from aiohttp import WSMsgType, client_exceptions
|
|||
import pytest
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.components.cloud import Cloud, iot, auth_api, MODE_DEV
|
||||
from homeassistant.components.cloud import (
|
||||
Cloud, iot, auth_api, MODE_DEV, STORAGE_ENABLE_ALEXA,
|
||||
STORAGE_ENABLE_GOOGLE)
|
||||
from tests.components.alexa import test_smart_home as test_alexa
|
||||
from tests.common import mock_coro
|
||||
|
||||
from . import mock_cloud_prefs
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_client():
|
||||
|
@ -284,6 +288,8 @@ def test_handler_alexa(hass):
|
|||
})
|
||||
assert setup
|
||||
|
||||
mock_cloud_prefs(hass)
|
||||
|
||||
resp = yield from iot.async_handle_alexa(
|
||||
hass, hass.data['cloud'],
|
||||
test_alexa.get_new_request('Alexa.Discovery', 'Discover'))
|
||||
|
@ -299,6 +305,20 @@ def test_handler_alexa(hass):
|
|||
assert device['manufacturerName'] == 'Home Assistant'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_handler_alexa_disabled(hass, mock_cloud_fixture):
|
||||
"""Test handler Alexa when user has disabled it."""
|
||||
mock_cloud_fixture[STORAGE_ENABLE_ALEXA] = False
|
||||
|
||||
resp = yield from iot.async_handle_alexa(
|
||||
hass, hass.data['cloud'],
|
||||
test_alexa.get_new_request('Alexa.Discovery', 'Discover'))
|
||||
|
||||
assert resp['event']['header']['namespace'] == 'Alexa'
|
||||
assert resp['event']['header']['name'] == 'ErrorResponse'
|
||||
assert resp['event']['payload']['type'] == 'BRIDGE_UNREACHABLE'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_handler_google_actions(hass):
|
||||
"""Test handler Google Actions."""
|
||||
|
@ -327,6 +347,8 @@ def test_handler_google_actions(hass):
|
|||
})
|
||||
assert setup
|
||||
|
||||
mock_cloud_prefs(hass)
|
||||
|
||||
reqid = '5711642932632160983'
|
||||
data = {'requestId': reqid, 'inputs': [{'intent': 'action.devices.SYNC'}]}
|
||||
|
||||
|
@ -351,6 +373,24 @@ def test_handler_google_actions(hass):
|
|||
assert device['roomHint'] == 'living room'
|
||||
|
||||
|
||||
async def test_handler_google_actions_disabled(hass, mock_cloud_fixture):
|
||||
"""Test handler Google Actions when user has disabled it."""
|
||||
mock_cloud_fixture[STORAGE_ENABLE_GOOGLE] = False
|
||||
|
||||
with patch('homeassistant.components.cloud.Cloud.async_start',
|
||||
return_value=mock_coro()):
|
||||
assert await async_setup_component(hass, 'cloud', {})
|
||||
|
||||
reqid = '5711642932632160983'
|
||||
data = {'requestId': reqid, 'inputs': [{'intent': 'action.devices.SYNC'}]}
|
||||
|
||||
resp = await iot.async_handle_google_actions(
|
||||
hass, hass.data['cloud'], data)
|
||||
|
||||
assert resp['requestId'] == reqid
|
||||
assert resp['payload']['errorCode'] == 'deviceTurnedOff'
|
||||
|
||||
|
||||
async def test_refresh_token_expired(hass):
|
||||
"""Test handling Unauthenticated error raised if refresh token expired."""
|
||||
cloud = Cloud(hass, MODE_DEV, None, None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue