Find referenced labels in automations & scripts (#113812)

This commit is contained in:
Franck Nijhof 2024-03-19 16:28:37 +01:00 committed by GitHub
parent ea443af557
commit 670bd97777
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 217 additions and 1 deletions

View file

@ -1563,6 +1563,8 @@ async def test_extraction_functions_not_setup(hass: HomeAssistant) -> None:
assert automation.entities_in_automation(hass, "automation.test") == []
assert automation.automations_with_floor(hass, "floor-in-both") == []
assert automation.floors_in_automation(hass, "automation.test") == []
assert automation.automations_with_label(hass, "label-in-both") == []
assert automation.labels_in_automation(hass, "automation.test") == []
async def test_extraction_functions_unknown_automation(hass: HomeAssistant) -> None:
@ -1573,6 +1575,7 @@ async def test_extraction_functions_unknown_automation(hass: HomeAssistant) -> N
assert automation.devices_in_automation(hass, "automation.unknown") == []
assert automation.entities_in_automation(hass, "automation.unknown") == []
assert automation.floors_in_automation(hass, "automation.unknown") == []
assert automation.labels_in_automation(hass, "automation.unknown") == []
async def test_extraction_functions_unavailable_automation(hass: HomeAssistant) -> None:
@ -1600,6 +1603,8 @@ async def test_extraction_functions_unavailable_automation(hass: HomeAssistant)
assert automation.entities_in_automation(hass, entity_id) == []
assert automation.automations_with_floor(hass, "floor-in-both") == []
assert automation.floors_in_automation(hass, entity_id) == []
assert automation.automations_with_label(hass, "label-in-both") == []
assert automation.labels_in_automation(hass, entity_id) == []
async def test_extraction_functions(
@ -1703,6 +1708,10 @@ async def test_extraction_functions(
"service": "test.test",
"target": {"floor_id": "floor-in-both"},
},
{
"service": "test.test",
"target": {"label_id": "label-in-both"},
},
],
},
{
@ -1830,6 +1839,14 @@ async def test_extraction_functions(
"service": "test.test",
"target": {"floor_id": "floor-in-last"},
},
{
"service": "test.test",
"target": {"label_id": "label-in-both"},
},
{
"service": "test.test",
"target": {"label_id": "label-in-last"},
},
],
},
]
@ -1880,6 +1897,14 @@ async def test_extraction_functions(
"floor-in-both",
"floor-in-last",
}
assert set(automation.automations_with_label(hass, "label-in-both")) == {
"automation.test1",
"automation.test3",
}
assert set(automation.labels_in_automation(hass, "automation.test3")) == {
"label-in-both",
"label-in-last",
}
assert automation.blueprint_in_automation(hass, "automation.test3") is None