Use real devices in device_tracker device condition tests (#102707)
This commit is contained in:
parent
14485af22d
commit
9cf9b36637
1 changed files with 29 additions and 7 deletions
|
@ -110,10 +110,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_HOME)
|
hass.states.async_set(entry.entity_id, STATE_HOME)
|
||||||
|
|
||||||
|
@ -128,7 +139,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_home",
|
"type": "is_home",
|
||||||
}
|
}
|
||||||
|
@ -150,7 +161,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_not_home",
|
"type": "is_not_home",
|
||||||
}
|
}
|
||||||
|
@ -184,10 +195,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_HOME)
|
hass.states.async_set(entry.entity_id, STATE_HOME)
|
||||||
|
|
||||||
|
@ -202,7 +224,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_home",
|
"type": "is_home",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue