Skip to content

Commit

Permalink
Use real devices in alarm_control_panel device action tests (#102716)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Oct 24, 2023
1 parent 2e9a3e8 commit a448763
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions tests/components/alarm_control_panel/test_device_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,17 +426,25 @@ async def test_get_action_capabilities_arm_code_legacy(

async def test_action(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
enable_custom_integrations: None,
) -> None:
"""Test for turn_on and turn_off actions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()

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")},
)
entity_entry = entity_registry.async_get_or_create(
DOMAIN,
"test",
platform.ENTITIES["no_arm_code"].unique_id,
device_id=device_entry.id,
)

assert await async_setup_component(
Expand All @@ -451,7 +459,7 @@ async def test_action(
},
"action": {
"domain": DOMAIN,
"device_id": "abcdefgh",
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": "arm_away",
},
Expand All @@ -463,7 +471,7 @@ async def test_action(
},
"action": {
"domain": DOMAIN,
"device_id": "abcdefgh",
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": "arm_home",
},
Expand All @@ -475,7 +483,7 @@ async def test_action(
},
"action": {
"domain": DOMAIN,
"device_id": "abcdefgh",
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": "arm_night",
},
Expand All @@ -487,7 +495,7 @@ async def test_action(
},
"action": {
"domain": DOMAIN,
"device_id": "abcdefgh",
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": "arm_vacation",
},
Expand All @@ -496,7 +504,7 @@ async def test_action(
"trigger": {"platform": "event", "event_type": "test_event_disarm"},
"action": {
"domain": DOMAIN,
"device_id": "abcdefgh",
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": "disarm",
"code": "1234",
Expand All @@ -509,7 +517,7 @@ async def test_action(
},
"action": {
"domain": DOMAIN,
"device_id": "abcdefgh",
"device_id": device_entry.id,
"entity_id": entity_entry.id,
"type": "trigger",
},
Expand Down Expand Up @@ -549,17 +557,25 @@ async def test_action(

async def test_action_legacy(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
entity_registry: er.EntityRegistry,
enable_custom_integrations: None,
) -> None:
"""Test for turn_on and turn_off actions."""
platform = getattr(hass.components, f"test.{DOMAIN}")
platform.init()

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")},
)
entity_entry = entity_registry.async_get_or_create(
DOMAIN,
"test",
platform.ENTITIES["no_arm_code"].unique_id,
device_id=device_entry.id,
)

assert await async_setup_component(
Expand All @@ -574,7 +590,7 @@ async def test_action_legacy(
},
"action": {
"domain": DOMAIN,
"device_id": "abcdefgh",
"device_id": device_entry.id,
"entity_id": entity_entry.entity_id,
"type": "arm_away",
},
Expand Down

0 comments on commit a448763

Please sign in to comment.