mirror of
https://github.com/home-assistant/core.git
synced 2025-05-01 12:47:53 +00:00
Use real devices in lock device trigger tests (#102690)
This commit is contained in:
parent
691de148cf
commit
f9fa1edabf
@ -185,10 +185,21 @@ async def test_get_trigger_capabilities_legacy(
|
|||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_state_change(
|
async def test_if_fires_on_state_change(
|
||||||
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 triggers firing."""
|
"""Test for turn_on and turn_off triggers firing."""
|
||||||
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_UNLOCKED)
|
hass.states.async_set(entry.entity_id, STATE_UNLOCKED)
|
||||||
|
|
||||||
@ -201,7 +212,7 @@ async def test_if_fires_on_state_change(
|
|||||||
"trigger": {
|
"trigger": {
|
||||||
"platform": "device",
|
"platform": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "locked",
|
"type": "locked",
|
||||||
},
|
},
|
||||||
@ -220,7 +231,7 @@ async def test_if_fires_on_state_change(
|
|||||||
"trigger": {
|
"trigger": {
|
||||||
"platform": "device",
|
"platform": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "unlocked",
|
"type": "unlocked",
|
||||||
},
|
},
|
||||||
@ -259,10 +270,21 @@ async def test_if_fires_on_state_change(
|
|||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_state_change_legacy(
|
async def test_if_fires_on_state_change_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 triggers firing."""
|
"""Test for turn_on and turn_off triggers firing."""
|
||||||
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_UNLOCKED)
|
hass.states.async_set(entry.entity_id, STATE_UNLOCKED)
|
||||||
|
|
||||||
@ -275,7 +297,7 @@ async def test_if_fires_on_state_change_legacy(
|
|||||||
"trigger": {
|
"trigger": {
|
||||||
"platform": "device",
|
"platform": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.entity_id,
|
"entity_id": entry.entity_id,
|
||||||
"type": "locked",
|
"type": "locked",
|
||||||
},
|
},
|
||||||
@ -305,10 +327,21 @@ async def test_if_fires_on_state_change_legacy(
|
|||||||
|
|
||||||
|
|
||||||
async def test_if_fires_on_state_change_with_for(
|
async def test_if_fires_on_state_change_with_for(
|
||||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, calls
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
entity_registry: er.EntityRegistry,
|
||||||
|
calls,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test for triggers firing with delay."""
|
"""Test for triggers firing with delay."""
|
||||||
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_UNLOCKED)
|
hass.states.async_set(entry.entity_id, STATE_UNLOCKED)
|
||||||
|
|
||||||
@ -321,7 +354,7 @@ async def test_if_fires_on_state_change_with_for(
|
|||||||
"trigger": {
|
"trigger": {
|
||||||
"platform": "device",
|
"platform": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "locked",
|
"type": "locked",
|
||||||
"for": {"seconds": 5},
|
"for": {"seconds": 5},
|
||||||
@ -346,7 +379,7 @@ async def test_if_fires_on_state_change_with_for(
|
|||||||
"trigger": {
|
"trigger": {
|
||||||
"platform": "device",
|
"platform": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "unlocking",
|
"type": "unlocking",
|
||||||
"for": {"seconds": 5},
|
"for": {"seconds": 5},
|
||||||
@ -371,7 +404,7 @@ async def test_if_fires_on_state_change_with_for(
|
|||||||
"trigger": {
|
"trigger": {
|
||||||
"platform": "device",
|
"platform": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "jammed",
|
"type": "jammed",
|
||||||
"for": {"seconds": 5},
|
"for": {"seconds": 5},
|
||||||
@ -396,7 +429,7 @@ async def test_if_fires_on_state_change_with_for(
|
|||||||
"trigger": {
|
"trigger": {
|
||||||
"platform": "device",
|
"platform": "device",
|
||||||
"domain": DOMAIN,
|
"domain": DOMAIN,
|
||||||
"device_id": "",
|
"device_id": device_entry.id,
|
||||||
"entity_id": entry.id,
|
"entity_id": entry.id,
|
||||||
"type": "locking",
|
"type": "locking",
|
||||||
"for": {"seconds": 5},
|
"for": {"seconds": 5},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user