1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Google assistant sync (#13392)

* Add Google Assistant Sync API

* Update const.py

* Async/await
This commit is contained in:
Paulus Schoutsen
2018-03-23 12:13:52 -07:00
committed by GitHub
parent 2532d67b9a
commit 4bd6776443
5 changed files with 71 additions and 26 deletions

View File

@@ -11,6 +11,9 @@ from homeassistant.components.cloud import DOMAIN, auth_api, iot
from tests.common import mock_coro
GOOGLE_ACTIONS_SYNC_URL = 'https://api-test.hass.io/google_actions_sync'
@pytest.fixture
def cloud_client(hass, aiohttp_client):
"""Fixture that can fetch from the cloud client."""
@@ -23,6 +26,7 @@ def cloud_client(hass, aiohttp_client):
'user_pool_id': 'user_pool_id',
'region': 'region',
'relayer': 'relayer',
'google_actions_sync_url': GOOGLE_ACTIONS_SYNC_URL,
}
}))
hass.data['cloud']._decode_claims = \
@@ -38,6 +42,21 @@ def mock_cognito():
yield mock_cog()
async def test_google_actions_sync(mock_cognito, cloud_client, aioclient_mock):
"""Test syncing Google Actions."""
aioclient_mock.post(GOOGLE_ACTIONS_SYNC_URL)
req = await cloud_client.post('/api/cloud/google_actions/sync')
assert req.status == 200
async def test_google_actions_sync_fails(mock_cognito, cloud_client,
aioclient_mock):
"""Test syncing Google Actions gone bad."""
aioclient_mock.post(GOOGLE_ACTIONS_SYNC_URL, status=403)
req = await cloud_client.post('/api/cloud/google_actions/sync')
assert req.status == 403
@asyncio.coroutine
def test_account_view_no_account(cloud_client):
"""Test fetching account if no account available."""