Allow easier customization of whole domain, entity lists, globs. (#5215)

This commit is contained in:
andrey-git 2017-01-22 21:19:50 +02:00 committed by Johann Kellerman
parent ab19577322
commit addc2c4340
8 changed files with 285 additions and 48 deletions

View file

@ -165,6 +165,25 @@ def test_entity_ids():
]
def test_ensure_list_csv():
"""Test ensure_list_csv."""
schema = vol.Schema(cv.ensure_list_csv)
options = (
None,
12,
[],
['string'],
'string1,string2'
)
for value in options:
schema(value)
assert schema('string1, string2 ') == [
'string1', 'string2'
]
def test_event_schema():
"""Test event_schema validation."""
options = (
@ -429,6 +448,15 @@ def test_has_at_least_one_key():
schema(value)
def test_ordered_dict_only_dict():
"""Test ordered_dict validator."""
schema = vol.Schema(cv.ordered_dict(cv.match_all, cv.match_all))
for value in (None, [], 100, 'hello'):
with pytest.raises(vol.MultipleInvalid):
schema(value)
def test_ordered_dict_order():
"""Test ordered_dict validator."""
schema = vol.Schema(cv.ordered_dict(int, cv.string))