Use real devices in update device trigger tests (#102697)
This commit is contained in:
parent
8737d84d30
commit
d8baa38751
1 changed files with 28 additions and 4 deletions
|
@ -176,6 +176,7 @@ async def test_get_trigger_capabilities_legacy(
|
|||
|
||||
async def test_if_fires_on_state_change(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls: list[ServiceCall],
|
||||
enable_custom_integrations: None,
|
||||
|
@ -187,7 +188,14 @@ async def test_if_fires_on_state_change(
|
|||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
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("update.update_available")
|
||||
entity_registry.async_update_entity(entry.entity_id, device_id=device_entry.id)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -198,7 +206,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": "turned_on",
|
||||
},
|
||||
|
@ -222,7 +230,7 @@ async def test_if_fires_on_state_change(
|
|||
"trigger": {
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": "",
|
||||
"device_id": device_entry.id,
|
||||
"entity_id": "update.update_available",
|
||||
"type": "turned_off",
|
||||
},
|
||||
|
@ -270,6 +278,7 @@ async def test_if_fires_on_state_change(
|
|||
|
||||
async def test_if_fires_on_state_change_legacy(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls: list[ServiceCall],
|
||||
enable_custom_integrations: None,
|
||||
|
@ -281,7 +290,14 @@ async def test_if_fires_on_state_change_legacy(
|
|||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
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("update.update_available")
|
||||
entity_registry.async_update_entity(entry.entity_id, device_id=device_entry.id)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -292,7 +308,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_off",
|
||||
},
|
||||
|
@ -332,6 +348,7 @@ async def test_if_fires_on_state_change_legacy(
|
|||
|
||||
async def test_if_fires_on_state_change_with_for(
|
||||
hass: HomeAssistant,
|
||||
device_registry: dr.DeviceRegistry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
calls: list[ServiceCall],
|
||||
enable_custom_integrations: None,
|
||||
|
@ -343,7 +360,14 @@ async def test_if_fires_on_state_change_with_for(
|
|||
assert await async_setup_component(hass, DOMAIN, {DOMAIN: {CONF_PLATFORM: "test"}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
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("update.update_available")
|
||||
entity_registry.async_update_entity(entry.entity_id, device_id=device_entry.id)
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
|
@ -354,7 +378,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_off",
|
||||
"for": {"seconds": 5},
|
||||
|
|
Loading…
Add table
Reference in a new issue