1
0
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:
Paulus Schoutsen
2020-10-26 11:30:58 +01:00
committed by GitHub
parent 6645cb2637
commit e552c9ba96
5 changed files with 108 additions and 19 deletions

View File

@@ -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