Store original result on template results (#42391)
* Store original result on template results * Fix shell command test
This commit is contained in:
parent
9c6351c1b3
commit
1fb18580b2
5 changed files with 108 additions and 19 deletions
|
@ -9,7 +9,7 @@ import pytest
|
|||
import voluptuous as vol
|
||||
|
||||
import homeassistant
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers import config_validation as cv, template
|
||||
|
||||
from tests.async_mock import Mock, patch
|
||||
|
||||
|
@ -365,7 +365,7 @@ def test_slug():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_string():
|
||||
def test_string(hass):
|
||||
"""Test string validation."""
|
||||
schema = vol.Schema(cv.string)
|
||||
|
||||
|
@ -381,6 +381,19 @@ def test_string():
|
|||
for value in (True, 1, "hello"):
|
||||
schema(value)
|
||||
|
||||
# Test template support
|
||||
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 schema(result) == text
|
||||
|
||||
|
||||
def test_string_with_no_html():
|
||||
"""Test string with no html validation."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue