Fix config error for FTP links, add test (#12294)

This commit is contained in:
Rene Nulsch 2018-02-11 18:19:00 +01:00 committed by Paulus Schoutsen
parent b1c0cabe6c
commit 2edebfee0a
2 changed files with 15 additions and 1 deletions

View File

@ -22,9 +22,10 @@ CONF_RELATIVE_URL_REGEX = r'\A/'
DOMAIN = 'weblink'
ENTITIES_SCHEMA = vol.Schema({
# pylint: disable=no-value-for-parameter
vol.Required(CONF_URL): vol.Any(
vol.Match(CONF_RELATIVE_URL_REGEX, msg=CONF_RELATIVE_URL_ERROR_MSG),
cv.url),
vol.Url()),
vol.Required(CONF_NAME): cv.string,
vol.Optional(CONF_ICON): cv.icon,
})

View File

@ -91,6 +91,19 @@ class TestComponentWeblink(unittest.TestCase):
}
}))
def test_good_config_ftp_link(self):
"""Test if new entity is created."""
self.assertTrue(setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [
{
weblink.CONF_NAME: 'My FTP URL',
weblink.CONF_URL: 'ftp://somehost/'
},
],
}
}))
def test_entities_get_created(self):
"""Test if new entity is created."""
self.assertTrue(setup_component(self.hass, weblink.DOMAIN, {