This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

+97 -77
View File
@@ -20,104 +20,124 @@ class TestComponentWeblink(unittest.TestCase):
def test_bad_config(self):
"""Test if new entity is created."""
assert not setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [{}],
}
})
assert not setup_component(
self.hass, "weblink", {"weblink": {"entities": [{}]}}
)
def test_bad_config_relative_url(self):
"""Test if new entity is created."""
assert not setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [
{
weblink.CONF_NAME: 'My router',
weblink.CONF_URL: '../states/group.bla'
},
],
}
})
assert not setup_component(
self.hass,
"weblink",
{
"weblink": {
"entities": [
{
weblink.CONF_NAME: "My router",
weblink.CONF_URL: "../states/group.bla",
}
]
}
},
)
def test_bad_config_relative_file(self):
"""Test if new entity is created."""
assert not setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [
{
weblink.CONF_NAME: 'My group',
weblink.CONF_URL: 'group.bla'
},
],
}
})
assert not setup_component(
self.hass,
"weblink",
{
"weblink": {
"entities": [
{weblink.CONF_NAME: "My group", weblink.CONF_URL: "group.bla"}
]
}
},
)
def test_good_config_absolute_path(self):
"""Test if new entity is created."""
assert setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [
{
weblink.CONF_NAME: 'My second URL',
weblink.CONF_URL: '/states/group.bla'
},
],
}
})
assert setup_component(
self.hass,
"weblink",
{
"weblink": {
"entities": [
{
weblink.CONF_NAME: "My second URL",
weblink.CONF_URL: "/states/group.bla",
}
]
}
},
)
def test_good_config_path_short(self):
"""Test if new entity is created."""
assert setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [
{
weblink.CONF_NAME: 'My third URL',
weblink.CONF_URL: '/states'
},
],
}
})
assert setup_component(
self.hass,
"weblink",
{
"weblink": {
"entities": [
{weblink.CONF_NAME: "My third URL", weblink.CONF_URL: "/states"}
]
}
},
)
def test_good_config_path_directory(self):
"""Test if new entity is created."""
assert setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [
{
weblink.CONF_NAME: 'My last URL',
weblink.CONF_URL: '/states/bla/'
},
],
}
})
assert setup_component(
self.hass,
"weblink",
{
"weblink": {
"entities": [
{
weblink.CONF_NAME: "My last URL",
weblink.CONF_URL: "/states/bla/",
}
]
}
},
)
def test_good_config_ftp_link(self):
"""Test if new entity is created."""
assert setup_component(self.hass, 'weblink', {
'weblink': {
'entities': [
{
weblink.CONF_NAME: 'My FTP URL',
weblink.CONF_URL: 'ftp://somehost/'
},
],
}
})
assert 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."""
assert setup_component(self.hass, weblink.DOMAIN, {
weblink.DOMAIN: {
'entities': [
{
weblink.CONF_NAME: 'My router',
weblink.CONF_URL: 'http://127.0.0.1/'
},
]
}
})
assert setup_component(
self.hass,
weblink.DOMAIN,
{
weblink.DOMAIN: {
"entities": [
{
weblink.CONF_NAME: "My router",
weblink.CONF_URL: "http://127.0.0.1/",
}
]
}
},
)
state = self.hass.states.get('weblink.my_router')
state = self.hass.states.get("weblink.my_router")
assert state is not None
assert state.state == 'http://127.0.0.1/'
assert state.state == "http://127.0.0.1/"