From 4e066f468169f0613382a1f140f8026e24690ce0 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Wed, 19 Jun 2019 13:58:00 -0700 Subject: [PATCH] Fix sending update when not logged in (#24624) * Fix sending update when not logged in * Fix test --- homeassistant/components/cloud/client.py | 4 ++-- tests/components/cloud/test_client.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/cloud/client.py b/homeassistant/components/cloud/client.py index 92473974a9f..f8cfc255aa4 100644 --- a/homeassistant/components/cloud/client.py +++ b/homeassistant/components/cloud/client.py @@ -116,7 +116,7 @@ class AlexaConfig(alexa_config.AbstractConfig): if body['reason'] in ('RefreshTokenNotFound', 'UnknownRegion'): raise RequireRelink - return alexa_errors.NoTokenAvailable + raise alexa_errors.NoTokenAvailable self._token = body['access_token'] self._endpoint = body['event_endpoint'] @@ -239,7 +239,7 @@ class AlexaConfig(alexa_config.AbstractConfig): async def _handle_entity_registry_updated(self, event): """Handle when entity registry updated.""" - if not self.enabled: + if not self.enabled or not self._cloud.is_logged_in: return action = event.data['action'] diff --git a/tests/components/cloud/test_client.py b/tests/components/cloud/test_client.py index 7f4bf97086a..7d1afda7e6a 100644 --- a/tests/components/cloud/test_client.py +++ b/tests/components/cloud/test_client.py @@ -352,9 +352,9 @@ async def test_alexa_update_expose_trigger_sync(hass, cloud_prefs): assert to_remove == ['light.kitchen'] -async def test_alexa_entity_registry_sync(hass, cloud_prefs): +async def test_alexa_entity_registry_sync(hass, mock_cloud_login, cloud_prefs): """Test Alexa config responds to entity registry.""" - client.AlexaConfig(hass, ALEXA_SCHEMA({}), cloud_prefs, None) + client.AlexaConfig(hass, ALEXA_SCHEMA({}), cloud_prefs, hass.data['cloud']) with patch_sync_helper() as (to_update, to_remove): hass.bus.async_fire(EVENT_ENTITY_REGISTRY_UPDATED, {