mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Use real devices in select device condition tests (#102712)
This commit is contained in:
parent
1b61cd9179
commit
ff60a8072e
@ -115,10 +115,19 @@ async def test_get_conditions_hidden_auxiliary(
|
|||||||
async def test_if_selected_option(
|
async def test_if_selected_option(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
calls: list[ServiceCall],
|
calls: list[ServiceCall],
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for selected_option conditions."""
|
"""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(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
@ -131,7 +140,7 @@ async def test_if_selected_option(
|
|||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "selected_option",
|
"type": "selected_option",
|
||||||
"option": "option1",
|
"option": "option1",
|
||||||
@ -150,7 +159,7 @@ async def test_if_selected_option(
|
|||||||
{
|
{
|
||||||
"condition": "device",
|
"condition": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "selected_option",
|
"type": "selected_option",
|
||||||
"option": "option2",
|
"option": "option2",
|
||||||
@ -195,10 +204,19 @@ async def test_if_selected_option(
|
|||||||
async def test_if_selected_option_legacy(
|
async def test_if_selected_option_legacy(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
calls: list[ServiceCall],
|
calls: list[ServiceCall],
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
entity_registry: er.EntityRegistry,
|
entity_registry: er.EntityRegistry,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for selected_option conditions."""
|
"""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(
|
assert await async_setup_component(
|
||||||
hass,
|
hass,
|
||||||
@ -211,7 +229,7 @@ async def test_if_selected_option_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": "selected_option",
|
"type": "selected_option",
|
||||||
"option": "option1",
|
"option": "option1",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user