Remove validation of state==UNAVAILABLE on config entry unload in deCONZ test (#122558)
Only test remove entry marks entities unavailable in one place
This commit is contained in:
parent
c9b81a5c04
commit
b41b7aeb5b
16 changed files with 12 additions and 253 deletions
|
@ -66,7 +66,6 @@ class DeconzFan(DeconzDevice[Light], FanEntity):
|
|||
def __init__(self, device: Light, hub: DeconzHub) -> None:
|
||||
"""Set up fan."""
|
||||
super().__init__(device, hub)
|
||||
_attr_speed_count = len(ORDERED_NAMED_FAN_SPEEDS)
|
||||
if device.fan_speed in ORDERED_NAMED_FAN_SPEEDS:
|
||||
self._default_on_speed = device.fan_speed
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ from homeassistant.const import (
|
|||
STATE_ALARM_DISARMED,
|
||||
STATE_ALARM_PENDING,
|
||||
STATE_ALARM_TRIGGERED,
|
||||
STATE_UNAVAILABLE,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -158,10 +157,3 @@ async def test_alarm_control_panel(
|
|||
blocking=True,
|
||||
)
|
||||
assert aioclient_mock.mock_calls[0][2] == {"code0": code}
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
assert hass.states.get("alarm_control_panel.keypad").state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.components.deconz.const import (
|
|||
DOMAIN as DECONZ_DOMAIN,
|
||||
)
|
||||
from homeassistant.components.deconz.services import SERVICE_DEVICE_REFRESH
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -344,17 +344,6 @@ async def test_binary_sensors(
|
|||
await sensor_ws_data({"state": expected["websocket_event"]})
|
||||
assert hass.states.get(expected["entity_id"]).state == expected["next_state"]
|
||||
|
||||
# Unload entry
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
assert hass.states.get(expected["entity_id"]).state == STATE_UNAVAILABLE
|
||||
|
||||
# Remove entry
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
|
|
|
@ -8,7 +8,7 @@ import pytest
|
|||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.button import DOMAIN as BUTTON_DOMAIN, SERVICE_PRESS
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -101,14 +101,3 @@ async def test_button(
|
|||
blocking=True,
|
||||
)
|
||||
assert aioclient_mock.mock_calls[1][2] == expected["request_data"]
|
||||
|
||||
# Unload entry
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
assert hass.states.get(expected["entity_id"]).state == STATE_UNAVAILABLE
|
||||
|
||||
# Remove entry
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
|
@ -30,13 +30,7 @@ from homeassistant.components.deconz.climate import (
|
|||
DECONZ_PRESET_MANUAL,
|
||||
)
|
||||
from homeassistant.components.deconz.const import CONF_ALLOW_CLIP_SENSOR
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
ATTR_TEMPERATURE,
|
||||
STATE_OFF,
|
||||
STATE_UNAVAILABLE,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE, STATE_OFF, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -277,17 +271,6 @@ async def test_climate_device_without_cooling_support(
|
|||
blocking=True,
|
||||
)
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(states) == 1
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
|
|
|
@ -20,7 +20,7 @@ from homeassistant.components.cover import (
|
|||
SERVICE_STOP_COVER,
|
||||
SERVICE_STOP_COVER_TILT,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OPEN, STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OPEN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -114,17 +114,6 @@ async def test_cover(
|
|||
)
|
||||
assert aioclient_mock.mock_calls[4][2] == {"stop": True}
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(states) == 1
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"light_payload",
|
||||
|
|
|
@ -17,13 +17,7 @@ from homeassistant.components.deconz.deconz_event import (
|
|||
CONF_DECONZ_RELATIVE_ROTARY_EVENT,
|
||||
RELATIVE_ROTARY_DECONZ_TO_EVENT,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE_ID,
|
||||
CONF_EVENT,
|
||||
CONF_ID,
|
||||
CONF_UNIQUE_ID,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.const import CONF_DEVICE_ID, CONF_EVENT, CONF_ID, CONF_UNIQUE_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr
|
||||
|
||||
|
@ -166,17 +160,6 @@ async def test_deconz_events(
|
|||
await sensor_ws_data({"id": "1", "name": "other name"})
|
||||
assert len(captured_events) == 4
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(hass.states.async_all()) == 3
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"alarm_system_payload",
|
||||
|
@ -336,17 +319,6 @@ async def test_deconz_alarm_events(
|
|||
await sensor_ws_data({"state": {"panel": AncillaryControlPanel.ARMED_AWAY}})
|
||||
assert len(captured_events) == 4
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(hass.states.async_all()) == 4
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
|
@ -425,17 +397,6 @@ async def test_deconz_presence_events(
|
|||
await sensor_ws_data({"state": {"presenceevent": PresenceStatePresenceEvent.NINE}})
|
||||
assert len(captured_events) == 0
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(hass.states.async_all()) == 5
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
|
@ -513,17 +474,6 @@ async def test_deconz_relative_rotary_events(
|
|||
await sensor_ws_data({"name": "123"})
|
||||
assert len(captured_events) == 0
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(hass.states.async_all()) == 1
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
|
|
|
@ -13,13 +13,7 @@ from homeassistant.components.fan import (
|
|||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -128,14 +122,3 @@ async def test_fans(
|
|||
await light_ws_data({"state": {"speed": 5}})
|
||||
assert hass.states.get("fan.ceiling_fan").state == STATE_ON
|
||||
assert not hass.states.get("fan.ceiling_fan").attributes[ATTR_PERCENTAGE]
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(states) == 1
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
|
@ -32,7 +32,6 @@ from homeassistant.const import (
|
|||
ATTR_SUPPORTED_FEATURES,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
Platform,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -295,16 +294,6 @@ async def test_lights(
|
|||
config_entry = await config_entry_factory()
|
||||
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"light_payload",
|
||||
|
@ -762,16 +751,6 @@ async def test_groups(
|
|||
config_entry = await config_entry_factory()
|
||||
await snapshot_platform(hass, entity_registry, snapshot, config_entry.entry_id)
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"light_payload",
|
||||
|
|
|
@ -9,12 +9,7 @@ from homeassistant.components.lock import (
|
|||
SERVICE_LOCK,
|
||||
SERVICE_UNLOCK,
|
||||
)
|
||||
from homeassistant.const import (
|
||||
ATTR_ENTITY_ID,
|
||||
STATE_LOCKED,
|
||||
STATE_UNAVAILABLE,
|
||||
STATE_UNLOCKED,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_LOCKED, STATE_UNLOCKED
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .conftest import WebsocketDataType
|
||||
|
@ -78,17 +73,6 @@ async def test_lock_from_light(
|
|||
)
|
||||
assert aioclient_mock.mock_calls[2][2] == {"on": False}
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(states) == 1
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
|
@ -152,14 +136,3 @@ async def test_lock_from_sensor(
|
|||
blocking=True,
|
||||
)
|
||||
assert aioclient_mock.mock_calls[2][2] == {"lock": False}
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(states) == 2
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.components.number import (
|
|||
DOMAIN as NUMBER_DOMAIN,
|
||||
SERVICE_SET_VALUE,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
@ -136,14 +136,3 @@ async def test_number_entities(
|
|||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
# Unload entry
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
assert hass.states.get(expected["entity_id"]).state == STATE_UNAVAILABLE
|
||||
|
||||
# Remove entry
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
|
@ -8,7 +8,7 @@ import pytest
|
|||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.scene import DOMAIN as SCENE_DOMAIN, SERVICE_TURN_ON
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -64,17 +64,6 @@ async def test_scenes(
|
|||
)
|
||||
assert aioclient_mock.mock_calls[1][2] == {}
|
||||
|
||||
# Unload entry
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
assert hass.states.get(expected["entity_id"]).state == STATE_UNAVAILABLE
|
||||
|
||||
# Remove entry
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"group_payload",
|
||||
|
|
|
@ -16,7 +16,7 @@ from homeassistant.components.select import (
|
|||
DOMAIN as SELECT_DOMAIN,
|
||||
SERVICE_SELECT_OPTION,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.const import ATTR_ENTITY_ID, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -149,14 +149,3 @@ async def test_select(
|
|||
blocking=True,
|
||||
)
|
||||
assert aioclient_mock.mock_calls[1][2] == expected["request_data"]
|
||||
|
||||
# Unload entry
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
assert hass.states.get(expected["entity_id"]).state == STATE_UNAVAILABLE
|
||||
|
||||
# Remove entry
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
|
@ -10,7 +10,7 @@ from syrupy import SnapshotAssertion
|
|||
from homeassistant.components.deconz.const import CONF_ALLOW_CLIP_SENSOR
|
||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
|
||||
from homeassistant.const import STATE_UNAVAILABLE, Platform
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
@ -639,17 +639,6 @@ async def test_sensors(
|
|||
await sensor_ws_data(expected["websocket_event"])
|
||||
assert hass.states.get(expected["entity_id"]).state == expected["next_state"]
|
||||
|
||||
# Unload entry
|
||||
|
||||
await hass.config_entries.async_unload(config_entry.entry_id)
|
||||
assert hass.states.get(expected["entity_id"]).state == STATE_UNAVAILABLE
|
||||
|
||||
# Remove entry
|
||||
|
||||
await hass.config_entries.async_remove(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sensor_payload",
|
||||
|
|
|
@ -11,7 +11,6 @@ from homeassistant.const import (
|
|||
SERVICE_TURN_ON,
|
||||
STATE_OFF,
|
||||
STATE_ON,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
|
@ -78,14 +77,3 @@ async def test_sirens(
|
|||
blocking=True,
|
||||
)
|
||||
assert aioclient_mock.mock_calls[3][2] == {"alert": "lselect", "ontime": 100}
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(states) == 1
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.switch import (
|
|||
SERVICE_TURN_OFF,
|
||||
SERVICE_TURN_ON,
|
||||
)
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON, STATE_UNAVAILABLE
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_OFF, STATE_ON
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
|
@ -92,17 +92,6 @@ async def test_power_plugs(
|
|||
)
|
||||
assert aioclient_mock.mock_calls[2][2] == {"on": False}
|
||||
|
||||
await hass.config_entries.async_unload(config_entry_setup.entry_id)
|
||||
|
||||
states = hass.states.async_all()
|
||||
assert len(states) == 4
|
||||
for state in states:
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
await hass.config_entries.async_remove(config_entry_setup.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"light_payload",
|
||||
|
|
Loading…
Add table
Reference in a new issue