2014-11-28 22:49:29 -08:00
|
|
|
"""
|
2015-01-08 20:05:12 -08:00
|
|
|
tests.test_component_demo
|
2014-11-30 23:14:08 -08:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2014-11-28 22:49:29 -08:00
|
|
|
|
|
|
|
Tests demo component.
|
|
|
|
"""
|
|
|
|
import unittest
|
|
|
|
|
2015-08-16 20:44:46 -07:00
|
|
|
import homeassistant.core as ha
|
2014-11-28 22:49:29 -08:00
|
|
|
import homeassistant.components.demo as demo
|
|
|
|
|
2015-08-04 18:15:22 +02:00
|
|
|
from tests.common import mock_http_component
|
2015-07-11 00:02:52 -07:00
|
|
|
|
2014-11-28 22:49:29 -08:00
|
|
|
|
|
|
|
class TestDemo(unittest.TestCase):
|
|
|
|
""" Test the demo module. """
|
|
|
|
|
|
|
|
def setUp(self): # pylint: disable=invalid-name
|
|
|
|
self.hass = ha.HomeAssistant()
|
2015-07-11 00:02:52 -07:00
|
|
|
mock_http_component(self.hass)
|
2014-11-28 22:49:29 -08:00
|
|
|
|
|
|
|
def tearDown(self): # pylint: disable=invalid-name
|
|
|
|
""" Stop down stuff we started. """
|
|
|
|
self.hass.stop()
|
|
|
|
|
2015-03-16 22:20:31 -07:00
|
|
|
def test_if_demo_state_shows_by_default(self):
|
|
|
|
""" Test if demo state shows if we give no configuration. """
|
|
|
|
demo.setup(self.hass, {demo.DOMAIN: {}})
|
|
|
|
|
|
|
|
self.assertIsNotNone(self.hass.states.get('a.Demo_Mode'))
|
|
|
|
|
2014-11-28 22:49:29 -08:00
|
|
|
def test_hiding_demo_state(self):
|
|
|
|
""" Test if you can hide the demo card. """
|
2015-03-16 22:20:31 -07:00
|
|
|
demo.setup(self.hass, {demo.DOMAIN: {'hide_demo_state': 1}})
|
2014-11-28 22:49:29 -08:00
|
|
|
|
|
|
|
self.assertIsNone(self.hass.states.get('a.Demo_Mode'))
|