* Use set not list * Events are not entities * Don't await unload_events * Remove checks of entities content in tests * List to set comprehension * Why is it so hard to remember that sets arent parenthesis...
This commit is contained in:
1 parent
8895752837
commit
66a8edb11e
12 files changed
+20
-67
No files matched your search
@@ -67,7 +67,6 @@ async def test_no_binary_sensors(hass):
|
||||
"""Test that no sensors in deconz results in no sensor entities."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 0
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@@ -81,7 +80,6 @@ async def test_binary_sensors(hass):
|
||||
assert "binary_sensor.clip_presence_sensor" not in gateway.deconz_ids
|
||||
assert "binary_sensor.vibration_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 2
|
||||
|
||||
presence_sensor = hass.states.get("binary_sensor.presence_sensor")
|
||||
assert presence_sensor.state == "off"
|
||||
@@ -113,7 +111,6 @@ async def test_binary_sensors(hass):
|
||||
await gateway.async_reset()
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 0
|
||||
|
||||
|
||||
async def test_allow_clip_sensor(hass):
|
||||
@@ -130,7 +127,6 @@ async def test_allow_clip_sensor(hass):
|
||||
assert "binary_sensor.clip_presence_sensor" in gateway.deconz_ids
|
||||
assert "binary_sensor.vibration_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 4
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 3
|
||||
|
||||
presence_sensor = hass.states.get("binary_sensor.presence_sensor")
|
||||
assert presence_sensor.state == "off"
|
||||
@@ -154,7 +150,6 @@ async def test_allow_clip_sensor(hass):
|
||||
assert "binary_sensor.clip_presence_sensor" not in gateway.deconz_ids
|
||||
assert "binary_sensor.vibration_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 2
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: True}
|
||||
@@ -166,14 +161,12 @@ async def test_allow_clip_sensor(hass):
|
||||
assert "binary_sensor.clip_presence_sensor" in gateway.deconz_ids
|
||||
assert "binary_sensor.vibration_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 4
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 3
|
||||
|
||||
|
||||
async def test_add_new_binary_sensor(hass):
|
||||
"""Test that adding a new binary sensor works."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 0
|
||||
|
||||
state_added_event = {
|
||||
"t": "event",
|
||||
@@ -189,4 +182,3 @@ async def test_add_new_binary_sensor(hass):
|
||||
|
||||
presence_sensor = hass.states.get("binary_sensor.presence_sensor")
|
||||
assert presence_sensor.state == "off"
|
||||
assert len(gateway.entities[binary_sensor.DOMAIN]) == 1
|
||||
@@ -59,7 +59,6 @@ async def test_no_sensors(hass):
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 0
|
||||
|
||||
|
||||
async def test_climate_devices(hass):
|
||||
@@ -73,7 +72,6 @@ async def test_climate_devices(hass):
|
||||
assert "climate.presence_sensor" not in gateway.deconz_ids
|
||||
assert "climate.clip_thermostat" not in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 1
|
||||
|
||||
thermostat = hass.states.get("climate.thermostat")
|
||||
assert thermostat.state == "auto"
|
||||
@@ -183,7 +181,6 @@ async def test_climate_devices(hass):
|
||||
await gateway.async_reset()
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 0
|
||||
|
||||
|
||||
async def test_clip_climate_device(hass):
|
||||
@@ -201,7 +198,6 @@ async def test_clip_climate_device(hass):
|
||||
assert "climate.presence_sensor" not in gateway.deconz_ids
|
||||
assert "climate.clip_thermostat" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 4
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 2
|
||||
|
||||
thermostat = hass.states.get("climate.thermostat")
|
||||
assert thermostat.state == "auto"
|
||||
@@ -229,7 +225,6 @@ async def test_clip_climate_device(hass):
|
||||
assert "climate.presence_sensor" not in gateway.deconz_ids
|
||||
assert "climate.clip_thermostat" not in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 1
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: True}
|
||||
@@ -242,7 +237,6 @@ async def test_clip_climate_device(hass):
|
||||
assert "climate.presence_sensor" not in gateway.deconz_ids
|
||||
assert "climate.clip_thermostat" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 4
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 2
|
||||
|
||||
|
||||
async def test_verify_state_update(hass):
|
||||
@@ -274,7 +268,6 @@ async def test_add_new_climate_device(hass):
|
||||
"""Test that adding a new climate device works."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 0
|
||||
|
||||
state_added_event = {
|
||||
"t": "event",
|
||||
@@ -290,4 +283,3 @@ async def test_add_new_climate_device(hass):
|
||||
|
||||
thermostat = hass.states.get("climate.thermostat")
|
||||
assert thermostat.state == "auto"
|
||||
assert len(gateway.entities[climate.DOMAIN]) == 1
|
||||
@@ -67,7 +67,6 @@ async def test_no_covers(hass):
|
||||
"""Test that no cover entities are created."""
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(gateway.entities[cover.DOMAIN]) == 0
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
@@ -82,7 +81,6 @@ async def test_cover(hass):
|
||||
assert "cover.deconz_old_brightness_cover" in gateway.deconz_ids
|
||||
assert "cover.window_covering_controller" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 5
|
||||
assert len(gateway.entities[cover.DOMAIN]) == 4
|
||||
|
||||
level_controllable_cover = hass.states.get("cover.level_controllable_cover")
|
||||
assert level_controllable_cover.state == "open"
|
||||
@@ -160,4 +158,3 @@ async def test_cover(hass):
|
||||
await gateway.async_reset()
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[cover.DOMAIN]) == 0
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Test deCONZ remote events."""
|
||||
from copy import deepcopy
|
||||
|
||||
from homeassistant.components.deconz.deconz_event import CONF_DECONZ_EVENT, EVENT
|
||||
from homeassistant.components.deconz.deconz_event import CONF_DECONZ_EVENT
|
||||
|
||||
from .test_gateway import DECONZ_WEB_REQUEST, setup_deconz_integration
|
||||
|
||||
@@ -62,7 +62,6 @@ async def test_deconz_events(hass):
|
||||
assert "sensor.switch_2_battery_level" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 3
|
||||
assert len(gateway.events) == 5
|
||||
assert len(gateway.entities[EVENT]) == 5
|
||||
|
||||
switch_1 = hass.states.get("sensor.switch_1")
|
||||
assert switch_1 is None
|
||||
@@ -128,4 +127,3 @@ async def test_deconz_events(hass):
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.events) == 0
|
||||
assert len(gateway.entities[EVENT]) == 0
|
||||
@@ -95,7 +95,6 @@ async def test_no_lights_or_groups(hass):
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[light.DOMAIN]) == 0
|
||||
|
||||
|
||||
async def test_lights_and_groups(hass):
|
||||
@@ -112,7 +111,6 @@ async def test_lights_and_groups(hass):
|
||||
assert "light.on_off_light" in gateway.deconz_ids
|
||||
|
||||
assert len(hass.states.async_all()) == 6
|
||||
assert len(gateway.entities[light.DOMAIN]) == 5
|
||||
|
||||
rgb_light = hass.states.get("light.rgb_light")
|
||||
assert rgb_light.state == "on"
|
||||
@@ -258,7 +256,6 @@ async def test_lights_and_groups(hass):
|
||||
await gateway.async_reset()
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[light.DOMAIN]) == 0
|
||||
|
||||
|
||||
async def test_disable_light_groups(hass):
|
||||
@@ -278,7 +275,6 @@ async def test_disable_light_groups(hass):
|
||||
assert "light.on_off_switch" not in gateway.deconz_ids
|
||||
# 3 entities
|
||||
assert len(hass.states.async_all()) == 5
|
||||
assert len(gateway.entities[light.DOMAIN]) == 4
|
||||
|
||||
rgb_light = hass.states.get("light.rgb_light")
|
||||
assert rgb_light is not None
|
||||
@@ -304,7 +300,6 @@ async def test_disable_light_groups(hass):
|
||||
assert "light.on_off_switch" not in gateway.deconz_ids
|
||||
# 3 entities
|
||||
assert len(hass.states.async_all()) == 6
|
||||
assert len(gateway.entities[light.DOMAIN]) == 5
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_DECONZ_GROUPS: False}
|
||||
@@ -318,4 +313,3 @@ async def test_disable_light_groups(hass):
|
||||
assert "light.on_off_switch" not in gateway.deconz_ids
|
||||
# 3 entities
|
||||
assert len(hass.states.async_all()) == 5
|
||||
assert len(gateway.entities[light.DOMAIN]) == 4
|
||||
@@ -2,7 +2,6 @@
|
||||
from copy import deepcopy
|
||||
|
||||
from homeassistant.components import deconz
|
||||
from homeassistant.components.deconz.deconz_event import EVENT
|
||||
import homeassistant.components.sensor as sensor
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_BATTERY,
|
||||
@@ -97,7 +96,6 @@ async def test_no_sensors(hass):
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 0
|
||||
|
||||
|
||||
async def test_sensors(hass):
|
||||
@@ -116,7 +114,6 @@ async def test_sensors(hass):
|
||||
assert "sensor.consumption_sensor" in gateway.deconz_ids
|
||||
assert "sensor.clip_light_level_sensor" not in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 5
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 5
|
||||
|
||||
light_level_sensor = hass.states.get("sensor.light_level_sensor")
|
||||
assert light_level_sensor.state == "999.8"
|
||||
@@ -177,8 +174,6 @@ async def test_sensors(hass):
|
||||
await gateway.async_reset()
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
# Daylight sensor from deCONZ is added to set but is disabled by default
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 1
|
||||
|
||||
|
||||
async def test_allow_clip_sensors(hass):
|
||||
@@ -201,7 +196,6 @@ async def test_allow_clip_sensors(hass):
|
||||
assert "sensor.consumption_sensor" in gateway.deconz_ids
|
||||
assert "sensor.clip_light_level_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 6
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 6
|
||||
|
||||
light_level_sensor = hass.states.get("sensor.light_level_sensor")
|
||||
assert light_level_sensor.state == "999.8"
|
||||
@@ -249,7 +243,6 @@ async def test_allow_clip_sensors(hass):
|
||||
assert "sensor.consumption_sensor" in gateway.deconz_ids
|
||||
assert "sensor.clip_light_level_sensor" not in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 5
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 5
|
||||
|
||||
hass.config_entries.async_update_entry(
|
||||
gateway.config_entry, options={deconz.gateway.CONF_ALLOW_CLIP_SENSOR: True}
|
||||
@@ -267,7 +260,6 @@ async def test_allow_clip_sensors(hass):
|
||||
assert "sensor.consumption_sensor" in gateway.deconz_ids
|
||||
assert "sensor.clip_light_level_sensor" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 6
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 6
|
||||
|
||||
|
||||
async def test_add_new_sensor(hass):
|
||||
@@ -300,8 +292,6 @@ async def test_add_battery_later(hass):
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(gateway.events) == 1
|
||||
assert len(remote._callbacks) == 2
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 0
|
||||
assert len(gateway.entities[EVENT]) == 1
|
||||
|
||||
remote.update({"config": {"battery": 50}})
|
||||
await hass.async_block_till_done()
|
||||
@@ -312,5 +302,3 @@ async def test_add_battery_later(hass):
|
||||
|
||||
battery_sensor = hass.states.get("sensor.switch_1_battery_level")
|
||||
assert battery_sensor is not None
|
||||
assert len(gateway.entities[sensor.DOMAIN]) == 1
|
||||
assert len(gateway.entities[EVENT]) == 1
|
||||
@@ -64,7 +64,6 @@ async def test_no_switches(hass):
|
||||
gateway = await setup_deconz_integration(hass)
|
||||
assert len(gateway.deconz_ids) == 0
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[switch.DOMAIN]) == 0
|
||||
|
||||
|
||||
async def test_switches(hass):
|
||||
@@ -78,7 +77,6 @@ async def test_switches(hass):
|
||||
assert "switch.unsupported_switch" not in gateway.deconz_ids
|
||||
assert "switch.on_off_relay" in gateway.deconz_ids
|
||||
assert len(hass.states.async_all()) == 5
|
||||
assert len(gateway.entities[switch.DOMAIN]) == 4
|
||||
|
||||
on_off_switch = hass.states.get("switch.on_off_switch")
|
||||
assert on_off_switch.state == "on"
|
||||
@@ -175,4 +173,3 @@ async def test_switches(hass):
|
||||
await gateway.async_reset()
|
||||
|
||||
assert len(hass.states.async_all()) == 0
|
||||
assert len(gateway.entities[switch.DOMAIN]) == 0
|
||||
Reference in new issue
Block a user