Add support for complex template structures to data_template (#3255)
This commit is contained in:
parent
94e3986d54
commit
267cda447e
4 changed files with 55 additions and 5 deletions
|
@ -299,9 +299,7 @@ def test_template():
|
|||
"""Test template validator."""
|
||||
schema = vol.Schema(cv.template)
|
||||
|
||||
for value in (
|
||||
None, '{{ partial_print }', '{% if True %}Hello', {'dict': 'isbad'}
|
||||
):
|
||||
for value in (None, '{{ partial_print }', '{% if True %}Hello', ['test']):
|
||||
with pytest.raises(vol.MultipleInvalid):
|
||||
schema(value)
|
||||
|
||||
|
@ -313,6 +311,24 @@ def test_template():
|
|||
schema(value)
|
||||
|
||||
|
||||
def test_template_complex():
|
||||
"""Test template_complex validator."""
|
||||
schema = vol.Schema(cv.template_complex)
|
||||
|
||||
for value in (None, '{{ partial_print }', '{% if True %}Hello'):
|
||||
with pytest.raises(vol.MultipleInvalid):
|
||||
schema(value)
|
||||
|
||||
for value in (
|
||||
1, 'Hello',
|
||||
'{{ beer }}',
|
||||
'{% if 1 == 1 %}Hello{% else %}World{% endif %}',
|
||||
{'test': 1, 'test': '{{ beer }}'},
|
||||
['{{ beer }}', 1]
|
||||
):
|
||||
schema(value)
|
||||
|
||||
|
||||
def test_time_zone():
|
||||
"""Test time zone validation."""
|
||||
schema = vol.Schema(cv.time_zone)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue