2017-11-14 03:32:23 +11:00
|
|
|
"""The tests for google-assistant init."""
|
|
|
|
import asyncio
|
|
|
|
|
2019-12-09 20:00:14 +01:00
|
|
|
from homeassistant.components import google_assistant as ga
|
2019-10-03 04:02:38 -07:00
|
|
|
from homeassistant.core import Context
|
2017-11-14 03:32:23 +11:00
|
|
|
from homeassistant.setup import async_setup_component
|
|
|
|
|
|
|
|
GA_API_KEY = "Agdgjsj399sdfkosd932ksd"
|
|
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def test_request_sync_service(aioclient_mock, hass):
|
|
|
|
"""Test that it posts to the request_sync url."""
|
2019-07-31 12:25:30 -07:00
|
|
|
aioclient_mock.post(ga.const.REQUEST_SYNC_BASE_URL, status=200)
|
2017-11-14 03:32:23 +11:00
|
|
|
|
2019-07-31 12:25:30 -07:00
|
|
|
yield from async_setup_component(
|
|
|
|
hass,
|
|
|
|
"google_assistant",
|
|
|
|
{"google_assistant": {"project_id": "test_project", "api_key": GA_API_KEY}},
|
|
|
|
)
|
2017-11-14 03:32:23 +11:00
|
|
|
|
|
|
|
assert aioclient_mock.call_count == 0
|
2019-07-31 12:25:30 -07:00
|
|
|
yield from hass.services.async_call(
|
2019-10-03 04:02:38 -07:00
|
|
|
ga.const.DOMAIN,
|
|
|
|
ga.const.SERVICE_REQUEST_SYNC,
|
|
|
|
blocking=True,
|
|
|
|
context=Context(user_id="123"),
|
2019-07-31 12:25:30 -07:00
|
|
|
)
|
2017-11-14 03:32:23 +11:00
|
|
|
|
|
|
|
assert aioclient_mock.call_count == 1
|