Use real devices in humidifier device condition tests (#102709)

This commit is contained in:
Erik Montnemery 2023-10-24 23:34:31 +02:00 committed by GitHub
parent 3ed67f134f
commit 0e8bd9805a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -149,10 +149,21 @@ async def test_get_conditions_hidden_auxiliary(
async def test_if_state( async def test_if_state(
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
calls,
) -> None: ) -> None:
"""Test for turn_on and turn_off conditions.""" """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_ON, {ATTR_MODE: const.MODE_AWAY}) hass.states.async_set(entry.entity_id, STATE_ON, {ATTR_MODE: const.MODE_AWAY})
@ -167,7 +178,7 @@ async def test_if_state(
{ {
"condition": "device", "condition": "device",
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": device_entry.id,
"entity_id": entry.id, "entity_id": entry.id,
"type": "is_on", "type": "is_on",
} }
@ -186,7 +197,7 @@ async def test_if_state(
{ {
"condition": "device", "condition": "device",
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": device_entry.id,
"entity_id": entry.id, "entity_id": entry.id,
"type": "is_off", "type": "is_off",
} }
@ -205,7 +216,7 @@ async def test_if_state(
{ {
"condition": "device", "condition": "device",
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": device_entry.id,
"entity_id": entry.id, "entity_id": entry.id,
"type": "is_mode", "type": "is_mode",
"mode": "away", "mode": "away",
@ -254,10 +265,21 @@ async def test_if_state(
async def test_if_state_legacy( 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: ) -> None:
"""Test for turn_on and turn_off conditions.""" """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_ON, {ATTR_MODE: const.MODE_AWAY}) hass.states.async_set(entry.entity_id, STATE_ON, {ATTR_MODE: const.MODE_AWAY})
@ -272,7 +294,7 @@ async def test_if_state_legacy(
{ {
"condition": "device", "condition": "device",
"domain": DOMAIN, "domain": DOMAIN,
"device_id": "", "device_id": device_entry.id,
"entity_id": entry.entity_id, "entity_id": entry.entity_id,
"type": "is_mode", "type": "is_mode",
"mode": "away", "mode": "away",