Person schema for merge_packages #21307 (#21703)

* Person schema for merge_packages #21307

* empty list

* skip empty persons

* hound

* test schema

* ensure_none

* remove any test changes

* remove_falsy validator

* nice!

* coretests
This commit is contained in:
Johann Kellerman 2019-04-03 04:43:06 +02:00 committed by Paulus Schoutsen
parent 5613e8bb60
commit 3453d67cfe
4 changed files with 19 additions and 8 deletions

View file

@ -1,15 +1,15 @@
"""Test config validators."""
from datetime import timedelta, datetime, date
from datetime import date, datetime, timedelta
import enum
import os
from socket import _GLOBAL_DEFAULT_TIMEOUT
from unittest.mock import Mock, patch
import uuid
import homeassistant
import pytest
import voluptuous as vol
import homeassistant
import homeassistant.helpers.config_validation as cv
@ -291,6 +291,11 @@ def test_time_period():
assert -1 * timedelta(hours=1, minutes=15) == schema('-1:15')
def test_remove_falsy():
"""Test remove falsy."""
assert cv.remove_falsy([0, None, 1, "1", {}, [], ""]) == [1, "1"]
def test_service():
"""Test service validation."""
schema = vol.Schema(cv.service)
@ -908,7 +913,7 @@ def test_matches_regex():
schema(" nrtd ")
test_str = "This is a test including uiae."
assert (schema(test_str) == test_str)
assert schema(test_str) == test_str
def test_is_regex():
@ -982,6 +987,6 @@ def test_uuid4_hex(caplog):
# the 17th char should be 8-a
schema('a03d31b22eee4acc7b90eec40be6ed23')
hex = uuid.uuid4().hex
assert schema(hex) == hex
assert schema(hex.upper()) == hex
_hex = uuid.uuid4().hex
assert schema(_hex) == _hex
assert schema(_hex.upper()) == _hex