Entity Component to no longer generate automatic groups (#23789)

This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-01-07 17:30:53 +01:00
1 parent 13e6479b6e
commit 9aa02e35a7
41 files changed
+149 -377

No files matched your search

-7
View File
@@ -80,10 +80,6 @@ async def test_service_specify_data(hass, calls):
assert state is not None
assert state.attributes.get("last_triggered") == time
state = hass.states.get("group.all_automations")
assert state is not None
assert state.attributes.get("entity_id") == ("automation.hello",)
async def test_action_delay(hass, calls):
"""Test action delay."""
@@ -134,9 +130,6 @@ async def test_action_delay(hass, calls):
state = hass.states.get("automation.hello")
assert state is not None
assert state.attributes.get("last_triggered") == time
state = hass.states.get("group.all_automations")
assert state is not None
assert state.attributes.get("entity_id") == ("automation.hello",)
async def test_service_specify_entity_id(hass, calls):
+2 -2
View File
@@ -62,7 +62,7 @@ async def test_cover(hass):
assert "cover.level_controllable_cover" in gateway.deconz_ids
assert "cover.window_covering_device" in gateway.deconz_ids
assert "cover.unsupported_cover" not in gateway.deconz_ids
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 3
level_controllable_cover = hass.states.get("cover.level_controllable_cover")
assert level_controllable_cover.state == "open"
@@ -122,4 +122,4 @@ async def test_cover(hass):
await gateway.async_reset()
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 0
+5 -5
View File
@@ -91,8 +91,8 @@ async def test_lights_and_groups(hass):
assert "light.light_group" in gateway.deconz_ids
assert "light.empty_group" not in gateway.deconz_ids
assert "light.on_off_switch" not in gateway.deconz_ids
# 4 entities + 2 groups (one for switches and one for lights)
assert len(hass.states.async_all()) == 6
# 4 entities
assert len(hass.states.async_all()) == 4
rgb_light = hass.states.get("light.rgb_light")
assert rgb_light.state == "on"
@@ -200,7 +200,7 @@ async def test_lights_and_groups(hass):
await gateway.async_reset()
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 0
async def test_disable_light_groups(hass):
@@ -218,8 +218,8 @@ async def test_disable_light_groups(hass):
assert "light.light_group" not in gateway.deconz_ids
assert "light.empty_group" not in gateway.deconz_ids
assert "light.on_off_switch" not in gateway.deconz_ids
# 4 entities + 2 groups (one for switches and one for lights)
assert len(hass.states.async_all()) == 5
# 3 entities
assert len(hass.states.async_all()) == 3
rgb_light = hass.states.get("light.rgb_light")
assert rgb_light is not None
+2 -2
View File
@@ -68,7 +68,7 @@ async def test_switches(hass):
assert "switch.smart_plug" in gateway.deconz_ids
assert "switch.warning_device" in gateway.deconz_ids
assert "switch.unsupported_switch" not in gateway.deconz_ids
assert len(hass.states.async_all()) == 6
assert len(hass.states.async_all()) == 4
on_off_switch = hass.states.get("switch.on_off_switch")
assert on_off_switch.state == "on"
@@ -161,4 +161,4 @@ async def test_switches(hass):
await gateway.async_reset()
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 0
-9
View File
@@ -19,7 +19,6 @@ from homeassistant.components.vacuum import (
ATTR_PARAMS,
ATTR_STATUS,
DOMAIN,
ENTITY_ID_ALL_VACUUMS,
SERVICE_SEND_COMMAND,
SERVICE_SET_FAN_SPEED,
STATE_CLEANING,
@@ -119,14 +118,6 @@ class TestVacuumDemo(unittest.TestCase):
self.hass.block_till_done()
assert not vacuum.is_on(self.hass, ENTITY_VACUUM_BASIC)
self.hass.states.set(ENTITY_ID_ALL_VACUUMS, STATE_ON)
self.hass.block_till_done()
assert vacuum.is_on(self.hass)
self.hass.states.set(ENTITY_ID_ALL_VACUUMS, STATE_OFF)
self.hass.block_till_done()
assert not vacuum.is_on(self.hass)
common.turn_on(self.hass, ENTITY_VACUUM_COMPLETE)
self.hass.block_till_done()
assert vacuum.is_on(self.hass, ENTITY_VACUUM_COMPLETE)
@@ -85,24 +85,31 @@ async def test_lights_on_when_sun_sets(hass, scanner):
async_fire_time_changed(hass, test_time)
await hass.async_block_till_done()
assert light.is_on(hass)
assert all(
light.is_on(hass, ent_id) for ent_id in hass.states.async_entity_ids("light")
)
async def test_lights_turn_off_when_everyone_leaves(hass, scanner):
async def test_lights_turn_off_when_everyone_leaves(hass):
"""Test lights turn off when everyone leaves the house."""
assert await async_setup_component(
hass, "light", {light.DOMAIN: {CONF_PLATFORM: "test"}}
)
await common_light.async_turn_on(hass)
hass.states.async_set("device_tracker.bla", STATE_HOME)
assert await async_setup_component(
hass, device_sun_light_trigger.DOMAIN, {device_sun_light_trigger.DOMAIN: {}}
)
assert light.is_on(hass)
hass.states.async_set(device_tracker.ENTITY_ID_ALL_DEVICES, STATE_NOT_HOME)
hass.states.async_set("device_tracker.bla", STATE_NOT_HOME)
await hass.async_block_till_done()
assert not light.is_on(hass)
assert all(
not light.is_on(hass, ent_id)
for ent_id in hass.states.async_entity_ids("light")
)
async def test_lights_turn_on_when_coming_home_after_sun_set(hass, scanner):
@@ -118,7 +125,10 @@ async def test_lights_turn_on_when_coming_home_after_sun_set(hass, scanner):
hass.states.async_set(DT_ENTITY_ID_FORMAT.format("device_2"), STATE_HOME)
await hass.async_block_till_done()
assert light.is_on(hass)
assert all(
light.is_on(hass, ent_id) for ent_id in hass.states.async_entity_ids("light")
)
async def test_lights_turn_on_when_coming_home_after_sun_set_person(hass, scanner):
@@ -133,8 +143,10 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person(hass, scanne
hass.states.async_set(device_2, STATE_NOT_HOME)
await hass.async_block_till_done()
assert not light.is_on(hass)
assert hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES).state == "not_home"
assert all(
not light.is_on(hass, ent_id)
for ent_id in hass.states.async_entity_ids("light")
)
assert hass.states.get(device_1).state == "not_home"
assert hass.states.get(device_2).state == "not_home"
@@ -152,7 +164,10 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person(hass, scanne
{device_sun_light_trigger.DOMAIN: {"device_group": "group.person_me"}},
)
assert not light.is_on(hass)
assert all(
not light.is_on(hass, ent_id)
for ent_id in hass.states.async_entity_ids("light")
)
assert hass.states.get(device_1).state == "not_home"
assert hass.states.get(device_2).state == "not_home"
assert hass.states.get("person.me").state == "not_home"
@@ -161,7 +176,10 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person(hass, scanne
hass.states.async_set(device_2, STATE_HOME)
await hass.async_block_till_done()
assert not light.is_on(hass)
assert all(
not light.is_on(hass, ent_id)
for ent_id in hass.states.async_entity_ids("light")
)
assert hass.states.get(device_1).state == "not_home"
assert hass.states.get(device_2).state == "home"
assert hass.states.get("person.me").state == "not_home"
@@ -170,7 +188,10 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person(hass, scanne
hass.states.async_set(device_1, STATE_HOME)
await hass.async_block_till_done()
assert light.is_on(hass)
assert all(
light.is_on(hass, ent_id)
for ent_id in hass.states.async_entity_ids("light")
)
assert hass.states.get(device_1).state == "home"
assert hass.states.get(device_2).state == "home"
assert hass.states.get("person.me").state == "home"
+1 -24
View File
@@ -12,7 +12,6 @@ from homeassistant.components import zone
import homeassistant.components.device_tracker as device_tracker
from homeassistant.components.device_tracker import const, legacy
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_ENTITY_PICTURE,
ATTR_FRIENDLY_NAME,
ATTR_GPS_ACCURACY,
@@ -319,29 +318,7 @@ async def test_device_hidden(hass, mock_device_tracker_conf):
assert hass.states.get(entity_id).attributes.get(ATTR_HIDDEN)
async def test_group_all_devices(hass, mock_device_tracker_conf):
"""Test grouping of devices."""
devices = mock_device_tracker_conf
dev_id = "test_entity"
entity_id = const.ENTITY_ID_FORMAT.format(dev_id)
device = legacy.Device(
hass, timedelta(seconds=180), True, dev_id, None, hide_if_away=True
)
devices.append(device)
scanner = getattr(hass.components, "test.device_tracker").SCANNER
scanner.reset()
with assert_setup_component(1, device_tracker.DOMAIN):
assert await async_setup_component(hass, device_tracker.DOMAIN, TEST_PLATFORM)
await hass.async_block_till_done()
state = hass.states.get(device_tracker.ENTITY_ID_ALL_DEVICES)
assert state is not None
assert STATE_NOT_HOME == state.state
assert (entity_id,) == state.attributes.get(ATTR_ENTITY_ID)
@patch("homeassistant.components.device_tracker.legacy.DeviceTracker.async_see")
@patch("homeassistant.components.device_tracker.legacy." "DeviceTracker.async_see")
async def test_see_service(mock_see, hass):
"""Test the see service with a unicode dev_id and NO MAC."""
with assert_setup_component(1, device_tracker.DOMAIN):
@@ -123,20 +123,6 @@ DEMO_DEVICES = [
"type": "action.devices.types.LIGHT",
"willReportState": False,
},
{
"id": "group.all_lights",
"name": {"name": "all lights"},
"traits": ["action.devices.traits.OnOff"],
"type": "action.devices.types.SWITCH",
"willReportState": False,
},
{
"id": "group.all_switches",
"name": {"name": "all switches"},
"traits": ["action.devices.traits.OnOff"],
"type": "action.devices.types.SWITCH",
"willReportState": False,
},
{
"id": "cover.living_room_window",
"name": {"name": "Living Room Window"},
@@ -165,13 +151,6 @@ DEMO_DEVICES = [
"type": "action.devices.types.BLINDS",
"willReportState": False,
},
{
"id": "group.all_covers",
"name": {"name": "all covers"},
"traits": ["action.devices.traits.OnOff"],
"type": "action.devices.types.SWITCH",
"willReportState": False,
},
{
"id": "media_player.bedroom",
"name": {"name": "Bedroom"},
@@ -226,13 +205,6 @@ DEMO_DEVICES = [
"type": "action.devices.types.FAN",
"willReportState": False,
},
{
"id": "group.all_fans",
"name": {"name": "all fans"},
"traits": ["action.devices.traits.OnOff"],
"type": "action.devices.types.SWITCH",
"willReportState": False,
},
{
"id": "climate.hvac",
"name": {"name": "Hvac"},
+18 -18
View File
@@ -258,8 +258,8 @@ async def test_lights(hass, mock_bridge):
mock_bridge.mock_light_responses.append(LIGHT_RESPONSE)
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 1
# 1 All Lights group, 2 lights
assert len(hass.states.async_all()) == 3
# 2 lights
assert len(hass.states.async_all()) == 2
lamp_1 = hass.states.get("light.hue_lamp_1")
assert lamp_1 is not None
@@ -313,8 +313,8 @@ async def test_groups(hass, mock_bridge):
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 2
# 1 all lights group, 2 hue group lights
assert len(hass.states.async_all()) == 3
# 2 hue group lights
assert len(hass.states.async_all()) == 2
lamp_1 = hass.states.get("light.group_1")
assert lamp_1 is not None
@@ -335,7 +335,7 @@ async def test_new_group_discovered(hass, mock_bridge):
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 2
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
new_group_response = dict(GROUP_RESPONSE)
new_group_response["3"] = {
@@ -365,7 +365,7 @@ async def test_new_group_discovered(hass, mock_bridge):
)
# 2x group update, 2x light update, 1 turn on request
assert len(mock_bridge.mock_requests) == 5
assert len(hass.states.async_all()) == 4
assert len(hass.states.async_all()) == 3
new_group = hass.states.get("light.group_3")
assert new_group is not None
@@ -380,7 +380,7 @@ async def test_new_light_discovered(hass, mock_bridge):
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 1
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
new_light_response = dict(LIGHT_RESPONSE)
new_light_response["3"] = {
@@ -418,7 +418,7 @@ async def test_new_light_discovered(hass, mock_bridge):
)
# 2x light update, 1 turn on request
assert len(mock_bridge.mock_requests) == 3
assert len(hass.states.async_all()) == 4
assert len(hass.states.async_all()) == 3
light = hass.states.get("light.hue_lamp_3")
assert light is not None
@@ -433,7 +433,7 @@ async def test_group_removed(hass, mock_bridge):
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 2
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
mock_bridge.mock_light_responses.append({})
mock_bridge.mock_group_responses.append({"1": GROUP_RESPONSE["1"]})
@@ -445,7 +445,7 @@ async def test_group_removed(hass, mock_bridge):
# 2x group update, 2x light update, 1 turn on request
assert len(mock_bridge.mock_requests) == 5
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 1
group = hass.states.get("light.group_1")
assert group is not None
@@ -460,7 +460,7 @@ async def test_light_removed(hass, mock_bridge):
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 1
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
mock_bridge.mock_light_responses.clear()
mock_bridge.mock_light_responses.append({"1": LIGHT_RESPONSE.get("1")})
@@ -472,7 +472,7 @@ async def test_light_removed(hass, mock_bridge):
# 2x light update, 1 turn on request
assert len(mock_bridge.mock_requests) == 3
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 1
light = hass.states.get("light.hue_lamp_1")
assert light is not None
@@ -489,7 +489,7 @@ async def test_other_group_update(hass, mock_bridge):
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 2
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
group_2 = hass.states.get("light.group_2")
assert group_2 is not None
@@ -526,7 +526,7 @@ async def test_other_group_update(hass, mock_bridge):
)
# 2x group update, 2x light update, 1 turn on request
assert len(mock_bridge.mock_requests) == 5
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
group_2 = hass.states.get("light.group_2")
assert group_2 is not None
@@ -540,7 +540,7 @@ async def test_other_light_update(hass, mock_bridge):
await setup_bridge(hass, mock_bridge)
assert len(mock_bridge.mock_requests) == 1
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
lamp_2 = hass.states.get("light.hue_lamp_2")
assert lamp_2 is not None
@@ -583,7 +583,7 @@ async def test_other_light_update(hass, mock_bridge):
)
# 2x light update, 1 turn on request
assert len(mock_bridge.mock_requests) == 3
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
lamp_2 = hass.states.get("light.hue_lamp_2")
assert lamp_2 is not None
@@ -641,7 +641,7 @@ async def test_light_turn_on_service(hass, mock_bridge):
"alert": "none",
}
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
light = hass.states.get("light.hue_lamp_2")
assert light is not None
@@ -685,7 +685,7 @@ async def test_light_turn_off_service(hass, mock_bridge):
assert mock_bridge.mock_requests[1]["json"] == {"on": False, "alert": "none"}
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
light = hass.states.get("light.hue_lamp_1")
assert light is not None
-6
View File
@@ -52,12 +52,6 @@ class TestLight(unittest.TestCase):
self.hass.states.set("light.test", STATE_OFF)
assert not light.is_on(self.hass, "light.test")
self.hass.states.set(light.ENTITY_ID_ALL_LIGHTS, STATE_ON)
assert light.is_on(self.hass)
self.hass.states.set(light.ENTITY_ID_ALL_LIGHTS, STATE_OFF)
assert not light.is_on(self.hass)
# Test turn_on
turn_on_calls = mock_service(self.hass, light.DOMAIN, SERVICE_TURN_ON)
+1 -2
View File
@@ -707,8 +707,7 @@ async def test_unique_id(hass, mqtt_mock):
async_fire_mqtt_message(hass, "test-topic", "payload")
assert len(hass.states.async_entity_ids()) == 2
# all vacuums group is 1, unique id created is 1
assert len(hass.states.async_entity_ids()) == 1
async def test_entity_device_info_with_identifier(hass, mqtt_mock):
+1 -2
View File
@@ -533,8 +533,7 @@ async def test_unique_id(hass, mqtt_mock):
async_fire_mqtt_message(hass, "test-topic", "payload")
assert len(hass.states.async_entity_ids()) == 2
# all vacuums group is 1, unique id created is 1
assert len(hass.states.async_entity_ids()) == 1
async def test_entity_device_info_with_identifier(hass, mqtt_mock):
+1 -2
View File
@@ -391,8 +391,7 @@ async def test_unique_id(hass):
async_fire_mqtt_message(hass, "test-topic", "payload")
assert len(hass.states.async_entity_ids()) == 2
# all switches group is 1, unique id created is 1
assert len(hass.states.async_entity_ids()) == 1
async def test_discovery_removal_switch(hass, mqtt_mock, caplog):
-6
View File
@@ -42,12 +42,6 @@ class TestRemote(unittest.TestCase):
self.hass.states.set("remote.test", STATE_OFF)
assert not remote.is_on(self.hass, "remote.test")
self.hass.states.set(remote.ENTITY_ID_ALL_REMOTES, STATE_ON)
assert remote.is_on(self.hass)
self.hass.states.set(remote.ENTITY_ID_ALL_REMOTES, STATE_OFF)
assert not remote.is_on(self.hass)
def test_turn_on(self):
"""Test turn_on."""
turn_on_calls = mock_service(self.hass, remote.DOMAIN, SERVICE_TURN_ON)
-4
View File
@@ -135,10 +135,6 @@ class TestScriptComponent(unittest.TestCase):
assert not script.is_on(self.hass, ENTITY_ID)
assert 0 == len(events)
state = self.hass.states.get("group.all_scripts")
assert state is not None
assert state.attributes.get("entity_id") == (ENTITY_ID,)
def test_toggle_service(self):
"""Test the toggling of a service."""
event = "test_event"
+1 -8
View File
@@ -4,7 +4,7 @@ import unittest
from homeassistant import core
from homeassistant.components import switch
from homeassistant.const import CONF_PLATFORM, STATE_OFF, STATE_ON
from homeassistant.const import CONF_PLATFORM
from homeassistant.setup import async_setup_component, setup_component
from tests.common import get_test_home_assistant, mock_entity_platform
@@ -33,8 +33,6 @@ class TestSwitch(unittest.TestCase):
assert setup_component(
self.hass, switch.DOMAIN, {switch.DOMAIN: {CONF_PLATFORM: "test"}}
)
assert switch.is_on(self.hass)
assert STATE_ON == self.hass.states.get(switch.ENTITY_ID_ALL_SWITCHES).state
assert switch.is_on(self.hass, self.switch_1.entity_id)
assert not switch.is_on(self.hass, self.switch_2.entity_id)
assert not switch.is_on(self.hass, self.switch_3.entity_id)
@@ -44,7 +42,6 @@ class TestSwitch(unittest.TestCase):
self.hass.block_till_done()
assert switch.is_on(self.hass)
assert not switch.is_on(self.hass, self.switch_1.entity_id)
assert switch.is_on(self.hass, self.switch_2.entity_id)
@@ -53,8 +50,6 @@ class TestSwitch(unittest.TestCase):
self.hass.block_till_done()
assert not switch.is_on(self.hass)
assert STATE_OFF == self.hass.states.get(switch.ENTITY_ID_ALL_SWITCHES).state
assert not switch.is_on(self.hass, self.switch_1.entity_id)
assert not switch.is_on(self.hass, self.switch_2.entity_id)
assert not switch.is_on(self.hass, self.switch_3.entity_id)
@@ -64,8 +59,6 @@ class TestSwitch(unittest.TestCase):
self.hass.block_till_done()
assert switch.is_on(self.hass)
assert STATE_ON == self.hass.states.get(switch.ENTITY_ID_ALL_SWITCHES).state
assert switch.is_on(self.hass, self.switch_1.entity_id)
assert switch.is_on(self.hass, self.switch_2.entity_id)
assert switch.is_on(self.hass, self.switch_3.entity_id)
@@ -97,7 +97,7 @@ async def test_no_clients(hass):
"""Test the update_clients function when no clients are found."""
await setup_unifi_integration(hass)
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 1
async def test_tracked_devices(hass):
@@ -112,7 +112,7 @@ async def test_tracked_devices(hass):
devices_response=[DEVICE_1, DEVICE_2],
known_wireless_clients=(CLIENT_4["mac"],),
)
assert len(hass.states.async_all()) == 6
assert len(hass.states.async_all()) == 5
client_1 = hass.states.get("device_tracker.client_1")
assert client_1 is not None
@@ -186,7 +186,7 @@ async def test_wireless_client_go_wired_issue(hass):
client_1_client["last_seen"] = dt_util.as_timestamp(dt_util.utcnow())
controller = await setup_unifi_integration(hass, clients_response=[client_1_client])
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
client_1 = hass.states.get("device_tracker.client_1")
assert client_1 is not None
@@ -262,7 +262,7 @@ async def test_restoring_client(hass):
clients_response=[CLIENT_2],
clients_all_response=[CLIENT_1],
)
assert len(hass.states.async_all()) == 4
assert len(hass.states.async_all()) == 3
device_1 = hass.states.get("device_tracker.client_1")
assert device_1 is not None
@@ -276,7 +276,7 @@ async def test_dont_track_clients(hass):
clients_response=[CLIENT_1],
devices_response=[DEVICE_1],
)
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
client_1 = hass.states.get("device_tracker.client_1")
assert client_1 is None
@@ -294,7 +294,7 @@ async def test_dont_track_devices(hass):
clients_response=[CLIENT_1],
devices_response=[DEVICE_1],
)
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
client_1 = hass.states.get("device_tracker.client_1")
assert client_1 is not None
@@ -311,7 +311,7 @@ async def test_dont_track_wired_clients(hass):
options={unifi.controller.CONF_TRACK_WIRED_CLIENTS: False},
clients_response=[CLIENT_1, CLIENT_2],
)
assert len(hass.states.async_all()) == 3
assert len(hass.states.async_all()) == 2
client_1 = hass.states.get("device_tracker.client_1")
assert client_1 is not None
+2 -2
View File
@@ -55,7 +55,7 @@ async def test_no_clients(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 1
async def test_sensors(hass):
@@ -71,7 +71,7 @@ async def test_sensors(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 6
assert len(hass.states.async_all()) == 5
wired_client_rx = hass.states.get("sensor.wired_client_name_rx")
assert wired_client_rx.state == "1234.0"
+10 -10
View File
@@ -208,7 +208,7 @@ async def test_no_clients(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 1
async def test_controller_not_client(hass):
@@ -224,7 +224,7 @@ async def test_controller_not_client(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 1
cloudkey = hass.states.get("switch.cloud_key")
assert cloudkey is None
@@ -245,7 +245,7 @@ async def test_not_admin(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 2
assert len(hass.states.async_all()) == 1
async def test_switches(hass):
@@ -263,7 +263,7 @@ async def test_switches(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 6
assert len(hass.states.async_all()) == 4
switch_1 = hass.states.get("switch.poe_client_1")
assert switch_1 is not None
@@ -298,7 +298,7 @@ async def test_new_client_discovered_on_block_control(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 4
assert len(hass.states.async_all()) == 2
controller.mock_client_all_responses.append([BLOCKED])
@@ -307,7 +307,7 @@ async def test_new_client_discovered_on_block_control(hass):
"switch", "turn_off", {"entity_id": "switch.block_client_1"}, blocking=True
)
assert len(controller.mock_requests) == 7
assert len(hass.states.async_all()) == 4
assert len(hass.states.async_all()) == 2
assert controller.mock_requests[3] == {
"json": {"mac": "00:00:00:00:01:01", "cmd": "block-sta"},
"method": "post",
@@ -338,7 +338,7 @@ async def test_new_client_discovered_on_poe_control(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 4
assert len(hass.states.async_all()) == 2
controller.mock_client_responses.append([CLIENT_1, CLIENT_2])
controller.mock_device_responses.append([DEVICE_1])
@@ -348,7 +348,7 @@ async def test_new_client_discovered_on_poe_control(hass):
"switch", "turn_off", {"entity_id": "switch.poe_client_1"}, blocking=True
)
assert len(controller.mock_requests) == 6
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 3
assert controller.mock_requests[3] == {
"json": {
"port_overrides": [{"port_idx": 1, "portconf_id": "1a1", "poe_mode": "off"}]
@@ -387,7 +387,7 @@ async def test_ignore_multiple_poe_clients_on_same_port(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 4
switch_1 = hass.states.get("switch.poe_client_1")
switch_2 = hass.states.get("switch.poe_client_2")
@@ -438,7 +438,7 @@ async def test_restoring_client(hass):
)
assert len(controller.mock_requests) == 3
assert len(hass.states.async_all()) == 5
assert len(hass.states.async_all()) == 3
device_1 = hass.states.get("switch.client_1")
assert device_1 is not None
+2 -2
View File
@@ -74,8 +74,8 @@ async def setup_verisure_locks(hass, config):
with mock_hub(config):
await async_setup_component(hass, VERISURE_DOMAIN, config)
await hass.async_block_till_done()
# lock.door_lock, group.all_locks, ethernet_status
assert len(hass.states.async_all()) == 3
# lock.door_lock, ethernet_status
assert len(hass.states.async_all()) == 2
async def test_verisure_no_default_code(hass):