mirror of
https://github.com/home-assistant/core.git
synced 2025-11-08 02:19:31 +00:00
Store original result on template results (#42391)
* Store original result on template results * Fix shell command test
This commit is contained in:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user