1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Add list areas function to template (#88441)

This commit is contained in:
Lucas Mindêllo de Andrade
2023-03-09 18:32:30 -03:00
committed by GitHub
parent 48fca3bb27
commit eed16dc185
2 changed files with 29 additions and 0 deletions

View File

@@ -2851,6 +2851,26 @@ async def test_device_attr(
assert info.rate_limit is None
async def test_areas(hass: HomeAssistant, area_registry: ar.AreaRegistry) -> None:
"""Test areas function."""
# Test no areas
info = render_to_info(hass, "{{ areas() }}")
assert_result_info(info, [])
assert info.rate_limit is None
# Test one area
area1 = area_registry.async_get_or_create("area1")
info = render_to_info(hass, "{{ areas() }}")
assert_result_info(info, [area1.id])
assert info.rate_limit is None
# Test multiple areas
area2 = area_registry.async_get_or_create("area2")
info = render_to_info(hass, "{{ areas() }}")
assert_result_info(info, [area1.id, area2.id])
assert info.rate_limit is None
async def test_area_id(
hass: HomeAssistant,
area_registry: ar.AreaRegistry,