Find referenced floors in automations & scripts (#113802)

This commit is contained in:
Franck Nijhof
2024-03-19 14:18:53 +01:00
committed by GitHub
parent 44211dc761
commit 38d0854b70
6 changed files with 232 additions and 10 deletions

View File

@ -684,11 +684,14 @@ async def test_extraction_functions_not_setup(hass: HomeAssistant) -> None:
assert script.devices_in_script(hass, "script.test") == []
assert script.scripts_with_entity(hass, "light.in_both") == []
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") == []
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.floors_in_script(hass, "script.unknown") == []
assert script.areas_in_script(hass, "script.unknown") == []
assert script.blueprint_in_script(hass, "script.unknown") is None
assert script.devices_in_script(hass, "script.unknown") == []
@ -712,6 +715,8 @@ async def test_extraction_functions_unavailable_script(hass: HomeAssistant) -> N
assert script.devices_in_script(hass, entity_id) == []
assert script.scripts_with_entity(hass, "light.in_both") == []
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) == []
async def test_extraction_functions(
@ -756,6 +761,10 @@ async def test_extraction_functions(
"service": "test.test",
"target": {"area_id": "area-in-both"},
},
{
"service": "test.test",
"target": {"floor_id": "floor-in-both"},
},
]
},
"test2": {
@ -804,6 +813,14 @@ async def test_extraction_functions(
"service": "test.test",
"target": {"area_id": "area-in-last"},
},
{
"service": "test.test",
"target": {"floor_id": "floor-in-both"},
},
{
"service": "test.test",
"target": {"floor_id": "floor-in-last"},
},
],
},
}
@ -835,6 +852,14 @@ async def test_extraction_functions(
"area-in-both",
"area-in-last",
}
assert set(script.scripts_with_floor(hass, "floor-in-both")) == {
"script.test1",
"script.test3",
}
assert set(script.floors_in_script(hass, "script.test3")) == {
"floor-in-both",
"floor-in-last",
}
assert script.blueprint_in_script(hass, "script.test3") is None