Load yaml using validator and include consider_home (#3743)

* Load yaml using validator, consider_home

* timedelta, track_if_away

* improve voluptuous

* Add default back

* Change time_period validation order
This commit is contained in:
Johann Kellerman authored and Paulus Schoutsen committed 2016-10-07 18:08:33 -07:00
1 parent b09b13f552
commit fb94aaa5a1
4 files changed
+53 -31

No files matched your search

+3 -2
View File
@@ -200,17 +200,18 @@ def test_time_period():
schema = vol.Schema(cv.time_period)
for value in (
None, '', 1234, 'hello:world', '12:', '12:34:56:78',
None, '', 'hello:world', '12:', '12:34:56:78',
{}, {'wrong_key': -10}
):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in (
'8:20', '23:59', '-8:20', '-23:59:59', '-48:00', {'minutes': 5}
'8:20', '23:59', '-8:20', '-23:59:59', '-48:00', {'minutes': 5}, 1, '5'
):
schema(value)
assert timedelta(seconds=180) == schema('180')
assert timedelta(hours=23, minutes=59) == schema('23:59')
assert -1 * timedelta(hours=1, minutes=15) == schema('-1:15')