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

Add is_hidden_entity test for Jinja templates (#89011)

This commit is contained in:
David Poll
2023-03-13 10:20:33 -07:00
committed by GitHub
parent 02389960ce
commit 0457bb2717
2 changed files with 30 additions and 0 deletions

View File

@@ -1443,6 +1443,26 @@ def test_if_state_exists(hass: HomeAssistant) -> None:
assert tpl.async_render() == "exists"
def test_is_hidden_entity(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
) -> None:
"""Test is_hidden_entity method."""
hidden_entity = entity_registry.async_get_or_create(
"sensor", "mock", "hidden", hidden_by=er.RegistryEntryHider.USER
)
visible_entity = entity_registry.async_get_or_create("sensor", "mock", "visible")
assert template.Template(
f"{{{{ is_hidden_entity('{hidden_entity.entity_id}') }}}}",
hass,
).async_render()
assert not template.Template(
f"{{{{ is_hidden_entity('{visible_entity.entity_id}') }}}}",
hass,
).async_render()
def test_is_state(hass: HomeAssistant) -> None:
"""Test is_state method."""
hass.states.async_set("test.object", "available")