mirror of
https://github.com/home-assistant/core.git
synced 2025-06-13 09:37:21 +00:00
Use fixtures in deCONZ sensor tests PT1 (#121116)
This commit is contained in:
parent
02e7707f91
commit
d429bcef16
@ -1,6 +1,8 @@
|
|||||||
"""deCONZ sensor platform tests."""
|
"""deCONZ sensor platform tests."""
|
||||||
|
|
||||||
|
from collections.abc import Callable
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from typing import Any
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@ -11,7 +13,7 @@ from homeassistant.components.sensor import (
|
|||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY
|
from homeassistant.config_entries import RELOAD_AFTER_UPDATE_DELAY, ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_DEVICE_CLASS,
|
ATTR_DEVICE_CLASS,
|
||||||
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||||
@ -982,12 +984,10 @@ async def test_sensors(
|
|||||||
assert len(hass.states.async_all()) == 0
|
assert len(hass.states.async_all()) == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_not_allow_clip_sensor(
|
@pytest.mark.parametrize(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
"sensor_payload",
|
||||||
) -> None:
|
[
|
||||||
"""Test that CLIP sensors are not allowed."""
|
{
|
||||||
data = {
|
|
||||||
"sensors": {
|
|
||||||
"1": {
|
"1": {
|
||||||
"name": "CLIP temperature sensor",
|
"name": "CLIP temperature sensor",
|
||||||
"type": "CLIPTemperature",
|
"type": "CLIPTemperature",
|
||||||
@ -996,22 +996,19 @@ async def test_not_allow_clip_sensor(
|
|||||||
"uniqueid": "00:00:00:00:00:00:00:02-00",
|
"uniqueid": "00:00:00:00:00:00:00:02-00",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
|
)
|
||||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
@pytest.mark.parametrize("config_entry_options", [{CONF_ALLOW_CLIP_SENSOR: False}])
|
||||||
await setup_deconz_integration(
|
@pytest.mark.usefixtures("config_entry_setup")
|
||||||
hass, aioclient_mock, options={CONF_ALLOW_CLIP_SENSOR: False}
|
async def test_not_allow_clip_sensor(hass: HomeAssistant) -> None:
|
||||||
)
|
"""Test that CLIP sensors are not allowed."""
|
||||||
|
|
||||||
assert len(hass.states.async_all()) == 0
|
assert len(hass.states.async_all()) == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_allow_clip_sensors(
|
@pytest.mark.parametrize(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
"sensor_payload",
|
||||||
) -> None:
|
[
|
||||||
"""Test that CLIP sensors can be allowed."""
|
{
|
||||||
data = {
|
|
||||||
"sensors": {
|
|
||||||
"1": {
|
"1": {
|
||||||
"name": "Light level sensor",
|
"name": "Light level sensor",
|
||||||
"type": "ZHALightLevel",
|
"type": "ZHALightLevel",
|
||||||
@ -1039,14 +1036,13 @@ async def test_allow_clip_sensors(
|
|||||||
"uniqueid": "/sensors/3",
|
"uniqueid": "/sensors/3",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
)
|
||||||
config_entry = await setup_deconz_integration(
|
@pytest.mark.parametrize("config_entry_options", [{CONF_ALLOW_CLIP_SENSOR: True}])
|
||||||
hass,
|
async def test_allow_clip_sensors(
|
||||||
aioclient_mock,
|
hass: HomeAssistant, config_entry_setup: ConfigEntry
|
||||||
options={CONF_ALLOW_CLIP_SENSOR: True},
|
) -> None:
|
||||||
)
|
"""Test that CLIP sensors can be allowed."""
|
||||||
|
|
||||||
assert len(hass.states.async_all()) == 4
|
assert len(hass.states.async_all()) == 4
|
||||||
assert hass.states.get("sensor.clip_light_level_sensor").state == "999.8"
|
assert hass.states.get("sensor.clip_light_level_sensor").state == "999.8"
|
||||||
assert hass.states.get("sensor.clip_flur").state == "0"
|
assert hass.states.get("sensor.clip_flur").state == "0"
|
||||||
@ -1054,7 +1050,7 @@ async def test_allow_clip_sensors(
|
|||||||
# Disallow clip sensors
|
# Disallow clip sensors
|
||||||
|
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
config_entry, options={CONF_ALLOW_CLIP_SENSOR: False}
|
config_entry_setup, options={CONF_ALLOW_CLIP_SENSOR: False}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
@ -1065,7 +1061,7 @@ async def test_allow_clip_sensors(
|
|||||||
# Allow clip sensors
|
# Allow clip sensors
|
||||||
|
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
config_entry, options={CONF_ALLOW_CLIP_SENSOR: True}
|
config_entry_setup, options={CONF_ALLOW_CLIP_SENSOR: True}
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
@ -1074,9 +1070,8 @@ async def test_allow_clip_sensors(
|
|||||||
assert hass.states.get("sensor.clip_flur").state == "0"
|
assert hass.states.get("sensor.clip_flur").state == "0"
|
||||||
|
|
||||||
|
|
||||||
async def test_add_new_sensor(
|
@pytest.mark.usefixtures("config_entry_setup")
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, mock_deconz_websocket
|
async def test_add_new_sensor(hass: HomeAssistant, mock_deconz_websocket) -> None:
|
||||||
) -> None:
|
|
||||||
"""Test that adding a new sensor works."""
|
"""Test that adding a new sensor works."""
|
||||||
event_added_sensor = {
|
event_added_sensor = {
|
||||||
"t": "event",
|
"t": "event",
|
||||||
@ -1093,8 +1088,6 @@ async def test_add_new_sensor(
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
await setup_deconz_integration(hass, aioclient_mock)
|
|
||||||
|
|
||||||
assert len(hass.states.async_all()) == 0
|
assert len(hass.states.async_all()) == 0
|
||||||
|
|
||||||
await mock_deconz_websocket(data=event_added_sensor)
|
await mock_deconz_websocket(data=event_added_sensor)
|
||||||
@ -1115,34 +1108,30 @@ BAD_SENSOR_DATA = [
|
|||||||
@pytest.mark.parametrize(("sensor_type", "sensor_property"), BAD_SENSOR_DATA)
|
@pytest.mark.parametrize(("sensor_type", "sensor_property"), BAD_SENSOR_DATA)
|
||||||
async def test_dont_add_sensor_if_state_is_none(
|
async def test_dont_add_sensor_if_state_is_none(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
aioclient_mock: AiohttpClientMocker,
|
config_entry_factory: Callable[[], ConfigEntry],
|
||||||
sensor_type,
|
sensor_payload: dict[str, Any],
|
||||||
sensor_property,
|
sensor_type: str,
|
||||||
|
sensor_property: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test sensor with scaled data is not created if state is None."""
|
"""Test sensor with scaled data is not created if state is None."""
|
||||||
data = {
|
sensor_payload |= {
|
||||||
"sensors": {
|
"1": {
|
||||||
"1": {
|
"name": "Sensor 1",
|
||||||
"name": "Sensor 1",
|
"type": sensor_type,
|
||||||
"type": sensor_type,
|
"state": {sensor_property: None},
|
||||||
"state": {sensor_property: None},
|
"config": {},
|
||||||
"config": {},
|
"uniqueid": "00:00:00:00:00:00:00:00-00",
|
||||||
"uniqueid": "00:00:00:00:00:00:00:00-00",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
await config_entry_factory()
|
||||||
await setup_deconz_integration(hass, aioclient_mock)
|
|
||||||
|
|
||||||
assert len(hass.states.async_all()) == 0
|
assert len(hass.states.async_all()) == 0
|
||||||
|
|
||||||
|
|
||||||
async def test_air_quality_sensor_without_ppb(
|
@pytest.mark.parametrize(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
"sensor_payload",
|
||||||
) -> None:
|
[
|
||||||
"""Test sensor with scaled data is not created if state is None."""
|
{
|
||||||
data = {
|
|
||||||
"sensors": {
|
|
||||||
"1": {
|
"1": {
|
||||||
"config": {
|
"config": {
|
||||||
"on": True,
|
"on": True,
|
||||||
@ -1163,23 +1152,18 @@ async def test_air_quality_sensor_without_ppb(
|
|||||||
"uniqueid": "00:00:00:00:00:00:00:00-02-fdef",
|
"uniqueid": "00:00:00:00:00:00:00:00-02-fdef",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
)
|
||||||
await setup_deconz_integration(hass, aioclient_mock)
|
@pytest.mark.usefixtures("config_entry_setup")
|
||||||
|
async def test_air_quality_sensor_without_ppb(hass: HomeAssistant) -> None:
|
||||||
|
"""Test sensor with scaled data is not created if state is None."""
|
||||||
assert len(hass.states.async_all()) == 1
|
assert len(hass.states.async_all()) == 1
|
||||||
|
|
||||||
|
|
||||||
async def test_add_battery_later(
|
@pytest.mark.parametrize(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, mock_deconz_websocket
|
"sensor_payload",
|
||||||
) -> None:
|
[
|
||||||
"""Test that a battery sensor can be created later on.
|
{
|
||||||
|
|
||||||
Without an initial battery state a battery sensor
|
|
||||||
can be created once a value is reported.
|
|
||||||
"""
|
|
||||||
data = {
|
|
||||||
"sensors": {
|
|
||||||
"1": {
|
"1": {
|
||||||
"name": "Switch 1",
|
"name": "Switch 1",
|
||||||
"type": "ZHASwitch",
|
"type": "ZHASwitch",
|
||||||
@ -1195,10 +1179,15 @@ async def test_add_battery_later(
|
|||||||
"uniqueid": "00:00:00:00:00:00:00:00-00-0001",
|
"uniqueid": "00:00:00:00:00:00:00:00-00-0001",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
],
|
||||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
)
|
||||||
await setup_deconz_integration(hass, aioclient_mock)
|
@pytest.mark.usefixtures("config_entry_setup")
|
||||||
|
async def test_add_battery_later(hass: HomeAssistant, mock_deconz_websocket) -> None:
|
||||||
|
"""Test that a battery sensor can be created later on.
|
||||||
|
|
||||||
|
Without an initial battery state a battery sensor
|
||||||
|
can be created once a value is reported.
|
||||||
|
"""
|
||||||
assert len(hass.states.async_all()) == 0
|
assert len(hass.states.async_all()) == 0
|
||||||
|
|
||||||
event_changed_sensor = {
|
event_changed_sensor = {
|
||||||
@ -1230,155 +1219,151 @@ async def test_add_battery_later(
|
|||||||
|
|
||||||
@pytest.mark.parametrize("model_id", ["0x8030", "0x8031", "0x8034", "0x8035"])
|
@pytest.mark.parametrize("model_id", ["0x8030", "0x8031", "0x8034", "0x8035"])
|
||||||
async def test_special_danfoss_battery_creation(
|
async def test_special_danfoss_battery_creation(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, model_id
|
hass: HomeAssistant,
|
||||||
|
config_entry_factory: Callable[[], ConfigEntry],
|
||||||
|
sensor_payload: dict[str, Any],
|
||||||
|
model_id: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the special Danfoss battery creation works.
|
"""Test the special Danfoss battery creation works.
|
||||||
|
|
||||||
Normally there should only be one battery sensor per device from deCONZ.
|
Normally there should only be one battery sensor per device from deCONZ.
|
||||||
With specific Danfoss devices each endpoint can report its own battery state.
|
With specific Danfoss devices each endpoint can report its own battery state.
|
||||||
"""
|
"""
|
||||||
data = {
|
sensor_payload |= {
|
||||||
"sensors": {
|
"1": {
|
||||||
"1": {
|
"config": {
|
||||||
"config": {
|
"battery": 70,
|
||||||
"battery": 70,
|
"heatsetpoint": 2300,
|
||||||
"heatsetpoint": 2300,
|
"offset": 0,
|
||||||
"offset": 0,
|
"on": True,
|
||||||
"on": True,
|
"reachable": True,
|
||||||
"reachable": True,
|
"schedule": {},
|
||||||
"schedule": {},
|
"schedule_on": False,
|
||||||
"schedule_on": False,
|
|
||||||
},
|
|
||||||
"ep": 1,
|
|
||||||
"etag": "982d9acc38bee5b251e24a9be26558e4",
|
|
||||||
"lastseen": "2021-02-15T12:23Z",
|
|
||||||
"manufacturername": "Danfoss",
|
|
||||||
"modelid": model_id,
|
|
||||||
"name": "0x8030",
|
|
||||||
"state": {
|
|
||||||
"lastupdated": "2021-02-15T12:23:07.994",
|
|
||||||
"on": False,
|
|
||||||
"temperature": 2307,
|
|
||||||
},
|
|
||||||
"swversion": "YYYYMMDD",
|
|
||||||
"type": "ZHAThermostat",
|
|
||||||
"uniqueid": "58:8e:81:ff:fe:00:11:22-01-0201",
|
|
||||||
},
|
},
|
||||||
"2": {
|
"ep": 1,
|
||||||
"config": {
|
"etag": "982d9acc38bee5b251e24a9be26558e4",
|
||||||
"battery": 86,
|
"lastseen": "2021-02-15T12:23Z",
|
||||||
"heatsetpoint": 2300,
|
"manufacturername": "Danfoss",
|
||||||
"offset": 0,
|
"modelid": model_id,
|
||||||
"on": True,
|
"name": "0x8030",
|
||||||
"reachable": True,
|
"state": {
|
||||||
"schedule": {},
|
"lastupdated": "2021-02-15T12:23:07.994",
|
||||||
"schedule_on": False,
|
"on": False,
|
||||||
},
|
"temperature": 2307,
|
||||||
"ep": 2,
|
|
||||||
"etag": "62f12749f9f51c950086aff37dd02b61",
|
|
||||||
"lastseen": "2021-02-15T12:23Z",
|
|
||||||
"manufacturername": "Danfoss",
|
|
||||||
"modelid": model_id,
|
|
||||||
"name": "0x8030",
|
|
||||||
"state": {
|
|
||||||
"lastupdated": "2021-02-15T12:23:22.399",
|
|
||||||
"on": False,
|
|
||||||
"temperature": 2316,
|
|
||||||
},
|
|
||||||
"swversion": "YYYYMMDD",
|
|
||||||
"type": "ZHAThermostat",
|
|
||||||
"uniqueid": "58:8e:81:ff:fe:00:11:22-02-0201",
|
|
||||||
},
|
},
|
||||||
"3": {
|
"swversion": "YYYYMMDD",
|
||||||
"config": {
|
"type": "ZHAThermostat",
|
||||||
"battery": 86,
|
"uniqueid": "58:8e:81:ff:fe:00:11:22-01-0201",
|
||||||
"heatsetpoint": 2350,
|
},
|
||||||
"offset": 0,
|
"2": {
|
||||||
"on": True,
|
"config": {
|
||||||
"reachable": True,
|
"battery": 86,
|
||||||
"schedule": {},
|
"heatsetpoint": 2300,
|
||||||
"schedule_on": False,
|
"offset": 0,
|
||||||
},
|
"on": True,
|
||||||
"ep": 3,
|
"reachable": True,
|
||||||
"etag": "f50061174bb7f18a3d95789bab8b646d",
|
"schedule": {},
|
||||||
"lastseen": "2021-02-15T12:23Z",
|
"schedule_on": False,
|
||||||
"manufacturername": "Danfoss",
|
|
||||||
"modelid": model_id,
|
|
||||||
"name": "0x8030",
|
|
||||||
"state": {
|
|
||||||
"lastupdated": "2021-02-15T12:23:25.466",
|
|
||||||
"on": False,
|
|
||||||
"temperature": 2337,
|
|
||||||
},
|
|
||||||
"swversion": "YYYYMMDD",
|
|
||||||
"type": "ZHAThermostat",
|
|
||||||
"uniqueid": "58:8e:81:ff:fe:00:11:22-03-0201",
|
|
||||||
},
|
},
|
||||||
"4": {
|
"ep": 2,
|
||||||
"config": {
|
"etag": "62f12749f9f51c950086aff37dd02b61",
|
||||||
"battery": 85,
|
"lastseen": "2021-02-15T12:23Z",
|
||||||
"heatsetpoint": 2300,
|
"manufacturername": "Danfoss",
|
||||||
"offset": 0,
|
"modelid": model_id,
|
||||||
"on": True,
|
"name": "0x8030",
|
||||||
"reachable": True,
|
"state": {
|
||||||
"schedule": {},
|
"lastupdated": "2021-02-15T12:23:22.399",
|
||||||
"schedule_on": False,
|
"on": False,
|
||||||
},
|
"temperature": 2316,
|
||||||
"ep": 4,
|
|
||||||
"etag": "eea97adf8ce1b971b8b6a3a31793f96b",
|
|
||||||
"lastseen": "2021-02-15T12:23Z",
|
|
||||||
"manufacturername": "Danfoss",
|
|
||||||
"modelid": model_id,
|
|
||||||
"name": "0x8030",
|
|
||||||
"state": {
|
|
||||||
"lastupdated": "2021-02-15T12:23:41.939",
|
|
||||||
"on": False,
|
|
||||||
"temperature": 2333,
|
|
||||||
},
|
|
||||||
"swversion": "YYYYMMDD",
|
|
||||||
"type": "ZHAThermostat",
|
|
||||||
"uniqueid": "58:8e:81:ff:fe:00:11:22-04-0201",
|
|
||||||
},
|
},
|
||||||
"5": {
|
"swversion": "YYYYMMDD",
|
||||||
"config": {
|
"type": "ZHAThermostat",
|
||||||
"battery": 83,
|
"uniqueid": "58:8e:81:ff:fe:00:11:22-02-0201",
|
||||||
"heatsetpoint": 2300,
|
},
|
||||||
"offset": 0,
|
"3": {
|
||||||
"on": True,
|
"config": {
|
||||||
"reachable": True,
|
"battery": 86,
|
||||||
"schedule": {},
|
"heatsetpoint": 2350,
|
||||||
"schedule_on": False,
|
"offset": 0,
|
||||||
},
|
"on": True,
|
||||||
"ep": 5,
|
"reachable": True,
|
||||||
"etag": "1f7cd1a5d66dc27ac5eb44b8c47362fb",
|
"schedule": {},
|
||||||
"lastseen": "2021-02-15T12:23Z",
|
"schedule_on": False,
|
||||||
"manufacturername": "Danfoss",
|
|
||||||
"modelid": model_id,
|
|
||||||
"name": "0x8030",
|
|
||||||
"state": {"lastupdated": "none", "on": False, "temperature": 2325},
|
|
||||||
"swversion": "YYYYMMDD",
|
|
||||||
"type": "ZHAThermostat",
|
|
||||||
"uniqueid": "58:8e:81:ff:fe:00:11:22-05-0201",
|
|
||||||
},
|
},
|
||||||
}
|
"ep": 3,
|
||||||
|
"etag": "f50061174bb7f18a3d95789bab8b646d",
|
||||||
|
"lastseen": "2021-02-15T12:23Z",
|
||||||
|
"manufacturername": "Danfoss",
|
||||||
|
"modelid": model_id,
|
||||||
|
"name": "0x8030",
|
||||||
|
"state": {
|
||||||
|
"lastupdated": "2021-02-15T12:23:25.466",
|
||||||
|
"on": False,
|
||||||
|
"temperature": 2337,
|
||||||
|
},
|
||||||
|
"swversion": "YYYYMMDD",
|
||||||
|
"type": "ZHAThermostat",
|
||||||
|
"uniqueid": "58:8e:81:ff:fe:00:11:22-03-0201",
|
||||||
|
},
|
||||||
|
"4": {
|
||||||
|
"config": {
|
||||||
|
"battery": 85,
|
||||||
|
"heatsetpoint": 2300,
|
||||||
|
"offset": 0,
|
||||||
|
"on": True,
|
||||||
|
"reachable": True,
|
||||||
|
"schedule": {},
|
||||||
|
"schedule_on": False,
|
||||||
|
},
|
||||||
|
"ep": 4,
|
||||||
|
"etag": "eea97adf8ce1b971b8b6a3a31793f96b",
|
||||||
|
"lastseen": "2021-02-15T12:23Z",
|
||||||
|
"manufacturername": "Danfoss",
|
||||||
|
"modelid": model_id,
|
||||||
|
"name": "0x8030",
|
||||||
|
"state": {
|
||||||
|
"lastupdated": "2021-02-15T12:23:41.939",
|
||||||
|
"on": False,
|
||||||
|
"temperature": 2333,
|
||||||
|
},
|
||||||
|
"swversion": "YYYYMMDD",
|
||||||
|
"type": "ZHAThermostat",
|
||||||
|
"uniqueid": "58:8e:81:ff:fe:00:11:22-04-0201",
|
||||||
|
},
|
||||||
|
"5": {
|
||||||
|
"config": {
|
||||||
|
"battery": 83,
|
||||||
|
"heatsetpoint": 2300,
|
||||||
|
"offset": 0,
|
||||||
|
"on": True,
|
||||||
|
"reachable": True,
|
||||||
|
"schedule": {},
|
||||||
|
"schedule_on": False,
|
||||||
|
},
|
||||||
|
"ep": 5,
|
||||||
|
"etag": "1f7cd1a5d66dc27ac5eb44b8c47362fb",
|
||||||
|
"lastseen": "2021-02-15T12:23Z",
|
||||||
|
"manufacturername": "Danfoss",
|
||||||
|
"modelid": model_id,
|
||||||
|
"name": "0x8030",
|
||||||
|
"state": {"lastupdated": "none", "on": False, "temperature": 2325},
|
||||||
|
"swversion": "YYYYMMDD",
|
||||||
|
"type": "ZHAThermostat",
|
||||||
|
"uniqueid": "58:8e:81:ff:fe:00:11:22-05-0201",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
|
||||||
await setup_deconz_integration(hass, aioclient_mock)
|
await config_entry_factory()
|
||||||
|
|
||||||
assert len(hass.states.async_all()) == 10
|
assert len(hass.states.async_all()) == 10
|
||||||
assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 5
|
assert len(hass.states.async_entity_ids(SENSOR_DOMAIN)) == 5
|
||||||
|
|
||||||
|
|
||||||
async def test_unsupported_sensor(
|
@pytest.mark.parametrize(
|
||||||
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
|
"sensor_payload",
|
||||||
) -> None:
|
[{"0": {"type": "not supported", "name": "name", "state": {}, "config": {}}}],
|
||||||
|
)
|
||||||
|
@pytest.mark.usefixtures("config_entry_setup")
|
||||||
|
async def test_unsupported_sensor(hass: HomeAssistant) -> None:
|
||||||
"""Test that unsupported sensors doesn't break anything."""
|
"""Test that unsupported sensors doesn't break anything."""
|
||||||
data = {
|
|
||||||
"sensors": {
|
|
||||||
"0": {"type": "not supported", "name": "name", "state": {}, "config": {}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
with patch.dict(DECONZ_WEB_REQUEST, data):
|
|
||||||
await setup_deconz_integration(hass, aioclient_mock)
|
|
||||||
|
|
||||||
assert len(hass.states.async_all()) == 0
|
assert len(hass.states.async_all()) == 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user