2016-03-09 09:25:50 +00:00
|
|
|
"""The tests for the weblink component."""
|
2016-01-31 08:50:03 +00:00
|
|
|
import unittest
|
|
|
|
|
2017-03-05 09:41:54 +00:00
|
|
|
from homeassistant.setup import setup_component
|
2016-01-31 08:50:03 +00:00
|
|
|
from homeassistant.components import weblink
|
|
|
|
|
2016-02-14 23:08:23 +00:00
|
|
|
from tests.common import get_test_home_assistant
|
2016-01-31 08:50:03 +00:00
|
|
|
|
2016-02-14 23:08:23 +00:00
|
|
|
|
|
|
|
class TestComponentWeblink(unittest.TestCase):
|
2016-03-09 09:25:50 +00:00
|
|
|
"""Test the Weblink component."""
|
2016-01-31 08:50:03 +00:00
|
|
|
|
|
|
|
def setUp(self):
|
2016-03-09 09:25:50 +00:00
|
|
|
"""Setup things to be run when tests are started."""
|
2016-02-14 23:08:23 +00:00
|
|
|
self.hass = get_test_home_assistant()
|
2016-01-31 08:50:03 +00:00
|
|
|
|
|
|
|
def tearDown(self):
|
2016-03-09 09:25:50 +00:00
|
|
|
"""Stop everything that was started."""
|
2016-01-31 08:50:03 +00:00
|
|
|
self.hass.stop()
|
|
|
|
|
2016-09-02 17:16:42 +00:00
|
|
|
def test_bad_config(self):
|
|
|
|
"""Test if new entity is created."""
|
2017-03-05 09:41:54 +00:00
|
|
|
self.assertFalse(setup_component(self.hass, 'weblink', {
|
2016-09-02 17:16:42 +00:00
|
|
|
'weblink': {
|
|
|
|
'entities': [{}],
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
|
2016-02-14 23:08:23 +00:00
|
|
|
def test_entities_get_created(self):
|
2016-03-09 09:25:50 +00:00
|
|
|
"""Test if new entity is created."""
|
2016-09-26 21:20:36 +00:00
|
|
|
self.assertTrue(setup_component(self.hass, weblink.DOMAIN, {
|
2016-01-31 08:50:03 +00:00
|
|
|
weblink.DOMAIN: {
|
|
|
|
'entities': [
|
|
|
|
{
|
2016-09-02 17:16:42 +00:00
|
|
|
weblink.CONF_NAME: 'My router',
|
|
|
|
weblink.CONF_URL: 'http://127.0.0.1/'
|
2016-01-31 08:50:03 +00:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}))
|
2016-02-14 23:08:23 +00:00
|
|
|
|
|
|
|
state = self.hass.states.get('weblink.my_router')
|
|
|
|
|
|
|
|
assert state is not None
|
|
|
|
assert state.state == 'http://127.0.0.1/'
|