Refactor deCONZ tests (#41362)
* Use hass.config_entries.async_unload * Return config_entry from setup_deconz_integration
This commit is contained in:
parent
42fb0e9545
commit
cbb4324c84
14 changed files with 130 additions and 102 deletions
|
@ -2,6 +2,7 @@
|
|||
from copy import deepcopy
|
||||
|
||||
from homeassistant.components import deconz
|
||||
from homeassistant.components.deconz.gateway import get_gateway_from_config_entry
|
||||
import homeassistant.components.lock as lock
|
||||
from homeassistant.const import STATE_LOCKED, STATE_UNLOCKED
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -48,7 +49,8 @@ async def test_locks(hass):
|
|||
"""Test that all supported lock entities are created."""
|
||||
data = deepcopy(DECONZ_WEB_REQUEST)
|
||||
data["lights"] = deepcopy(LOCKS)
|
||||
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()) == 1
|
||||
assert hass.states.get("lock.door_lock").state == STATE_UNLOCKED
|
||||
|
@ -96,6 +98,6 @@ async def test_locks(hass):
|
|||
await hass.async_block_till_done()
|
||||
set_callback.assert_called_with("put", "/lights/1/state", json={"on": False})
|
||||
|
||||
await gateway.async_reset()
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue