Store original result on template results (#42391)

* Store original result on template results

* Fix shell command test
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2020-10-26 11:30:58 +01:00
1 parent 6645cb2637
commit e552c9ba96
5 files changed
+108 -19

No files matched your search

+22
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