Refactor deCONZ tests (#41362)

* Use hass.config_entries.async_unload

* Return config_entry from setup_deconz_integration
This commit is contained in:
Robert Svensson authored and GitHub committed 2020-10-06 23:25:57 +02:00
1 parent 42fb0e9545
commit cbb4324c84
14 files changed
+130 -102

No files matched your search

+4 -2
View File
@@ -2,6 +2,7 @@
from copy import deepcopy
from homeassistant.components.deconz.deconz_event import CONF_DECONZ_EVENT
from homeassistant.components.deconz.gateway import get_gateway_from_config_entry
from .test_gateway import DECONZ_WEB_REQUEST, setup_deconz_integration
@@ -55,7 +56,8 @@ async def test_deconz_events(hass):
"""Test successful creation of deconz events."""
data = deepcopy(DECONZ_WEB_REQUEST)
data["sensors"] = deepcopy(SENSORS)
gateway = await setup_deconz_integration(hass, get_state_response=data)
config_entry = await setup_deconz_integration(hass, get_state_response=data)
gateway = get_gateway_from_config_entry(hass, config_entry)
assert len(hass.states.async_all()) == 3
assert len(gateway.events) == 5
@@ -112,7 +114,7 @@ async def test_deconz_events(hass):
"xy": [0.5982, 0.3897],
}
await gateway.async_reset()
await hass.config_entries.async_unload(config_entry.entry_id)
assert len(hass.states.async_all()) == 0
assert len(gateway.events) == 0