Skip to content

Commit

Permalink
Fix sending update when not logged in (#24624)
Browse files Browse the repository at this point in the history
* Fix sending update when not logged in

* Fix test
  • Loading branch information
balloob committed Jun 19, 2019
1 parent dbc4f28 commit 4e066f4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ async def async_get_access_token(self):
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']
Expand Down Expand Up @@ -239,7 +239,7 @@ async def _sync_helper(self, to_update, to_remove) -> bool:

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']
Expand Down
4 changes: 2 additions & 2 deletions tests/components/cloud/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 4e066f4

Please sign in to comment.