Find referenced labels in automations & scripts (#113812)
This commit is contained in:
parent
ea443af557
commit
670bd97777
6 changed files with 217 additions and 1 deletions
|
@ -686,11 +686,14 @@ async def test_extraction_functions_not_setup(hass: HomeAssistant) -> None:
|
|||
assert script.entities_in_script(hass, "script.test") == []
|
||||
assert script.scripts_with_floor(hass, "floor-in-both") == []
|
||||
assert script.floors_in_script(hass, "script.test") == []
|
||||
assert script.scripts_with_label(hass, "label-in-both") == []
|
||||
assert script.labels_in_script(hass, "script.test") == []
|
||||
|
||||
|
||||
async def test_extraction_functions_unknown_script(hass: HomeAssistant) -> None:
|
||||
"""Test extraction functions for an unknown script."""
|
||||
assert await async_setup_component(hass, DOMAIN, {})
|
||||
assert script.labels_in_script(hass, "script.unknown") == []
|
||||
assert script.floors_in_script(hass, "script.unknown") == []
|
||||
assert script.areas_in_script(hass, "script.unknown") == []
|
||||
assert script.blueprint_in_script(hass, "script.unknown") is None
|
||||
|
@ -717,6 +720,8 @@ async def test_extraction_functions_unavailable_script(hass: HomeAssistant) -> N
|
|||
assert script.entities_in_script(hass, entity_id) == []
|
||||
assert script.scripts_with_floor(hass, "floor-in-both") == []
|
||||
assert script.floors_in_script(hass, entity_id) == []
|
||||
assert script.scripts_with_label(hass, "label-in-both") == []
|
||||
assert script.labels_in_script(hass, entity_id) == []
|
||||
|
||||
|
||||
async def test_extraction_functions(
|
||||
|
@ -765,6 +770,10 @@ async def test_extraction_functions(
|
|||
"service": "test.test",
|
||||
"target": {"floor_id": "floor-in-both"},
|
||||
},
|
||||
{
|
||||
"service": "test.test",
|
||||
"target": {"label_id": "label-in-both"},
|
||||
},
|
||||
]
|
||||
},
|
||||
"test2": {
|
||||
|
@ -821,6 +830,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"},
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
|
@ -860,6 +877,14 @@ async def test_extraction_functions(
|
|||
"floor-in-both",
|
||||
"floor-in-last",
|
||||
}
|
||||
assert set(script.scripts_with_label(hass, "label-in-both")) == {
|
||||
"script.test1",
|
||||
"script.test3",
|
||||
}
|
||||
assert set(script.labels_in_script(hass, "script.test3")) == {
|
||||
"label-in-both",
|
||||
"label-in-last",
|
||||
}
|
||||
assert script.blueprint_in_script(hass, "script.test3") is None
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue