Fix sending update when not logged in (#24624)

* Fix sending update when not logged in

* Fix test
This commit is contained in:
Paulus Schoutsen 2019-06-19 13:58:00 -07:00 committed by GitHub
parent dbc4f285f1
commit 4e066f4681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -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']

View File

@ -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, {