Skip to content

Commit

Permalink
Fix deconz tests that have uncaught exceptions (home-assistant#33462)
Browse files Browse the repository at this point in the history
  • Loading branch information
azogue authored Mar 31, 2020
1 parent 977f1a6 commit f2f03cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
7 changes: 4 additions & 3 deletions homeassistant/components/deconz/deconz_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ async def async_added_to_hass(self):
async def async_will_remove_from_hass(self) -> None:
"""Disconnect device object when removed."""
self._device.remove_callback(self.async_update_callback)
del self.gateway.deconz_ids[self.entity_id]
for unsub_dispatcher in self.listeners:
unsub_dispatcher()
if self.entity_id in self.gateway.deconz_ids:
del self.gateway.deconz_ids[self.entity_id]
for unsub_dispatcher in self.listeners:
unsub_dispatcher()

async def async_remove_self(self, deconz_ids: list) -> None:
"""Schedule removal of this entity.
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/deconz/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@callback
def get_gateway_from_config_entry(hass, config_entry):
"""Return gateway with a matching bridge id."""
return hass.data[DOMAIN][config_entry.unique_id]
return hass.data[DOMAIN].get(config_entry.unique_id)


class DeconzGateway:
Expand Down Expand Up @@ -126,6 +126,8 @@ async def async_config_entry_updated(hass, entry) -> None:
Causes for this is either discovery updating host address or config entry options changing.
"""
gateway = get_gateway_from_config_entry(hass, entry)
if not gateway:
return
if gateway.api.host != entry.data[CONF_HOST]:
gateway.api.close()
gateway.api.host = entry.data[CONF_HOST]
Expand Down
5 changes: 0 additions & 5 deletions tests/ignore_uncaught_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
("tests.components.cast.test_media_player", "test_entry_setup_platform_not_ready"),
("tests.components.config.test_automation", "test_delete_automation"),
("tests.components.config.test_group", "test_update_device_config"),
("tests.components.deconz.test_binary_sensor", "test_allow_clip_sensor"),
("tests.components.deconz.test_climate", "test_clip_climate_device"),
("tests.components.deconz.test_init", "test_unload_entry_multiple_gateways"),
("tests.components.deconz.test_light", "test_disable_light_groups"),
("tests.components.deconz.test_sensor", "test_allow_clip_sensors"),
("tests.components.default_config.test_init", "test_setup"),
("tests.components.demo.test_init", "test_setting_up_demo"),
("tests.components.discovery.test_init", "test_discover_config_flow"),
Expand Down

0 comments on commit f2f03cf

Please sign in to comment.