mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Store original result on template results (#42391)
* Store original result on template results * Fix shell command test
This commit is contained in:
@@ -2651,3 +2651,25 @@ async def test_legacy_templates(hass):
|
||||
template.Template("{{ states.sensor.temperature.state }}", hass).async_render()
|
||||
== "12"
|
||||
)
|
||||
|
||||
|
||||
async def test_is_static_still_ast_evals(hass):
|
||||
"""Test is_static still convers to native type."""
|
||||
tpl = template.Template("[1, 2]", hass)
|
||||
assert tpl.is_static
|
||||
assert tpl.async_render() == [1, 2]
|
||||
|
||||
|
||||
async def test_result_wrappers(hass):
|
||||
"""Test result wrappers."""
|
||||
for text, native in (
|
||||
("[1, 2]", [1, 2]),
|
||||
("{1, 2}", {1, 2}),
|
||||
("(1, 2)", (1, 2)),
|
||||
('{"hello": True}', {"hello": True}),
|
||||
):
|
||||
tpl = template.Template(text, hass)
|
||||
result = tpl.async_render()
|
||||
assert isinstance(result, template.ResultWrapper)
|
||||
assert result == native
|
||||
assert result.render_result == text
|
||||
|
||||
Reference in New Issue
Block a user