mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Use real devices in media_player device trigger tests (#102691)
This commit is contained in:
parent
f9fa1edabf
commit
eac1d47ec6
@ -205,10 +205,21 @@ async def test_get_trigger_capabilities_legacy(
|
||||
|
||||
|
||||
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:
|
||||
"""Test 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_OFF)
|
||||
|
||||
@ -236,7 +247,7 @@ async def test_if_fires_on_state_change(
|
||||
"trigger": {
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": trigger,
|
||||
},
|
||||
@ -306,10 +317,21 @@ async def test_if_fires_on_state_change(
|
||||
|
||||
|
||||
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:
|
||||
"""Test 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_OFF)
|
||||
|
||||
@ -328,7 +350,7 @@ async def test_if_fires_on_state_change_legacy(
|
||||
"trigger": {
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.entity_id,
|
||||
"type": "turned_on",
|
||||
},
|
||||
@ -354,10 +376,21 @@ async def test_if_fires_on_state_change_legacy(
|
||||
|
||||
|
||||
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:
|
||||
"""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_OFF)
|
||||
|
||||
@ -370,7 +403,7 @@ async def test_if_fires_on_state_change_with_for(
|
||||
"trigger": {
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": entry.id,
|
||||
"type": "turned_on",
|
||||
"for": {"seconds": 5},
|
||||
|
Loading…
x
Reference in New Issue
Block a user