Add url to validation (#2874)

* Add url to validation

* Fix pylint issue

* Clean-up
This commit is contained in:
Fabian Affolter 2016-08-19 13:41:01 +02:00 committed by GitHub
parent c74e167a7b
commit ca1de9cac1
2 changed files with 29 additions and 2 deletions

View file

@ -48,10 +48,10 @@ def test_longitude():
def test_port():
"""Test tcp/udp network port."""
"""Test TCP/UDP network port."""
schema = vol.Schema(cv.port)
for value in('invalid', None, -1, 0, 80000, '81000'):
for value in ('invalid', None, -1, 0, 80000, '81000'):
with pytest.raises(vol.MultipleInvalid):
schema(value)
@ -59,6 +59,21 @@ def test_port():
schema(value)
def test_url():
"""Test URL."""
schema = vol.Schema(cv.url)
for value in ('invalid', None, 100, 'htp://ha.io', 'http//ha.io',
'http://??,**', 'https://??,**'):
with pytest.raises(vol.MultipleInvalid):
schema(value)
for value in ('http://localhost', 'https://localhost/test/index.html',
'http://home-assistant.io', 'http://home-assistant.io/test/',
'https://community.home-assistant.io/'):
assert schema(value)
def test_platform_config():
"""Test platform config validation."""
for value in (