Use real devices in vacuum device condition tests (#102715)

This commit is contained in:
Erik Montnemery 2023-10-24 23:38:01 +02:00 committed by GitHub
parent e761d5715b
commit e708faa4d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,10 +115,21 @@ async def test_get_conditions_hidden_auxiliary(
async def test_if_state(
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
calls,
) -> None:
"""Test for turn_on and turn_off conditions."""
entry = entity_registry.async_get_or_create(DOMAIN, "test", "5678")
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
entry = entity_registry.async_get_or_create(
DOMAIN, "test", "5678", device_id=device_entry.id
)
hass.states.async_set(entry.entity_id, STATE_DOCKED)
@ -133,7 +144,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_cleaning",
}
@ -151,7 +162,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_docked",
}
@ -189,10 +200,21 @@ async def test_if_state(
async def test_if_state_legacy(
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
calls,
) -> None:
"""Test for turn_on and turn_off conditions."""
entry = entity_registry.async_get_or_create(DOMAIN, "test", "5678")
config_entry = MockConfigEntry(domain="test", data={})
config_entry.add_to_hass(hass)
device_entry = device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
connections={(dr.CONNECTION_NETWORK_MAC, "12:34:56:AB:CD:EF")},
)
entry = entity_registry.async_get_or_create(
DOMAIN, "test", "5678", device_id=device_entry.id
)
hass.states.async_set(entry.entity_id, STATE_CLEANING)
@ -207,7 +229,7 @@ async def test_if_state_legacy(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.entity_id,
"type": "is_cleaning",
}