Use real devices in select device condition tests (#102712)

This commit is contained in:
Erik Montnemery 2023-10-24 23:37:16 +02:00 committed by GitHub
parent 1b61cd9179
commit ff60a8072e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,10 +115,19 @@ async def test_get_conditions_hidden_auxiliary(
async def test_if_selected_option(
hass: HomeAssistant,
calls: list[ServiceCall],
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
) -> None:
"""Test for selected_option 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
)
assert await async_setup_component(
hass,
@ -131,7 +140,7 @@ async def test_if_selected_option(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "selected_option",
"option": "option1",
@ -150,7 +159,7 @@ async def test_if_selected_option(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "selected_option",
"option": "option2",
@ -195,10 +204,19 @@ async def test_if_selected_option(
async def test_if_selected_option_legacy(
hass: HomeAssistant,
calls: list[ServiceCall],
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
) -> None:
"""Test for selected_option 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
)
assert await async_setup_component(
hass,
@ -211,7 +229,7 @@ async def test_if_selected_option_legacy(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.entity_id,
"type": "selected_option",
"option": "option1",