Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use real devices in alarm_control_panel device condition tests #102703

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 34 additions & 12 deletions tests/components/alarm_control_panel/test_device_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,21 @@ async def test_get_conditions_hidden_auxiliary(


async def test_if_state(
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls: list[ServiceCall]
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
calls: list[ServiceCall],
) -> None:
"""Test for all 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,
Expand All @@ -201,7 +212,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_triggered",
}
Expand All @@ -223,7 +234,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_disarmed",
}
Expand All @@ -245,7 +256,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_armed_home",
}
Expand All @@ -267,7 +278,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_armed_away",
}
Expand All @@ -289,7 +300,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_armed_night",
}
Expand All @@ -311,7 +322,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_armed_vacation",
}
Expand All @@ -333,7 +344,7 @@ async def test_if_state(
{
"condition": "device",
"domain": DOMAIN,
"device_id": "",
"device_id": device_entry.id,
"entity_id": entry.id,
"type": "is_armed_custom_bypass",
}
Expand Down Expand Up @@ -438,10 +449,21 @@ async def test_if_state(


async def test_if_state_legacy(
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls: list[ServiceCall]
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
calls: list[ServiceCall],
) -> None:
"""Test for all 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,
Expand All @@ -454,7 +476,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_triggered",
}
Expand Down