-
-
Save perosb/901318d85b418ed1d927fd82c74a816a to your computer and use it in GitHub Desktop.
ga hass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/homeassistant/components/google_assistant/__init__.py b/homeassistant/components/google_assistant/__init__.py | |
index c5904354b..8b4ac56fb 100644 | |
--- a/homeassistant/components/google_assistant/__init__.py | |
+++ b/homeassistant/components/google_assistant/__init__.py | |
@@ -56,9 +56,11 @@ CONFIG_SCHEMA = vol.Schema( | |
@bind_hass | |
[email protected] | |
def request_sync(hass): | |
"""Request sync.""" | |
- hass.services.call(DOMAIN, SERVICE_REQUEST_SYNC) | |
+ yield from hass.services.async_call(DOMAIN, | |
+ SERVICE_REQUEST_SYNC) | |
@asyncio.coroutine | |
@@ -93,7 +95,7 @@ def async_setup(hass: HomeAssistant, yaml_config: Dict[str, Any]): | |
return | |
except (asyncio.TimeoutError, aiohttp.ClientError): | |
_LOGGER.error("Could not contact Google for request_sync") | |
- return None | |
+ return | |
# Register service only if api key is provided | |
if api_key is not None: | |
diff --git a/tests/components/google_assistant/test_init.py b/tests/components/google_assistant/test_init.py | |
new file mode 100644 | |
index 000000000..47bce83a3 | |
--- /dev/null | |
+++ b/tests/components/google_assistant/test_init.py | |
@@ -0,0 +1,30 @@ | |
+"""The tests for google-assistant init.""" | |
+import asyncio | |
+ | |
+from homeassistant.setup import async_setup_component | |
+from homeassistant.components import google_assistant as ga | |
+ | |
+GA_API_KEY = "Agdgjsj399sdfkosd932ksd" | |
+GA_AGENT_USER_ID = "testid" | |
+ | |
+ | |
[email protected] | |
+def test_request_sync_service(hass, aioclient_mock): | |
+ """Test that it posts to the request_sync url.""" | |
+ aioclient_mock.post( | |
+ ga.const.REQUEST_SYNC_BASE_URL) | |
+ | |
+ yield from async_setup_component(hass, 'google_assistant', { | |
+ 'google_assistant': { | |
+ 'project_id': 'test_project', | |
+ 'client_id': 'r7328kwdsdfsdf03223409', | |
+ 'access_token': '8wdsfjsf932492342349234', | |
+ 'agent_user_id': GA_AGENT_USER_ID, | |
+ 'api_key': GA_API_KEY | |
+ }}) | |
+ | |
+ assert aioclient_mock.call_count == 0 | |
+ yield from hass.services.async_call(ga.DOMAIN, | |
+ ga.const.SERVICE_REQUEST_SYNC, | |
+ blocking=True) | |
+ assert aioclient_mock.call_count == 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment