mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Minor cleanup demo component
This commit is contained in:
parent
c2db17df9a
commit
bc3af134f9
@ -32,7 +32,13 @@ def setup(hass, config):
|
|||||||
hass.states.set('a.Demo_Mode', 'Enabled')
|
hass.states.set('a.Demo_Mode', 'Enabled')
|
||||||
|
|
||||||
# Setup sun
|
# Setup sun
|
||||||
loader.get_component('sun').setup(hass, config)
|
if not hass.config.latitude:
|
||||||
|
hass.config.latitude = '32.87336'
|
||||||
|
|
||||||
|
if not hass.config.longitude:
|
||||||
|
hass.config.longitude = '117.22743'
|
||||||
|
|
||||||
|
bootstrap.setup_component(hass, 'sun')
|
||||||
|
|
||||||
# Setup demo platforms
|
# Setup demo platforms
|
||||||
for component in COMPONENTS_WITH_DEMO_PLATFORM:
|
for component in COMPONENTS_WITH_DEMO_PLATFORM:
|
||||||
|
@ -4,13 +4,10 @@ tests.test_component_demo
|
|||||||
|
|
||||||
Tests demo component.
|
Tests demo component.
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-public-methods,protected-access
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import homeassistant as ha
|
import homeassistant as ha
|
||||||
import homeassistant.components.demo as demo
|
import homeassistant.components.demo as demo
|
||||||
from homeassistant.const import (
|
|
||||||
SERVICE_TURN_ON, SERVICE_TURN_OFF, STATE_ON, STATE_OFF, ATTR_ENTITY_ID)
|
|
||||||
|
|
||||||
|
|
||||||
class TestDemo(unittest.TestCase):
|
class TestDemo(unittest.TestCase):
|
||||||
@ -23,46 +20,6 @@ class TestDemo(unittest.TestCase):
|
|||||||
""" Stop down stuff we started. """
|
""" Stop down stuff we started. """
|
||||||
self.hass.stop()
|
self.hass.stop()
|
||||||
|
|
||||||
def test_services(self):
|
|
||||||
""" Test the demo services. """
|
|
||||||
# Test turning on and off different types
|
|
||||||
demo.setup(self.hass, {})
|
|
||||||
|
|
||||||
for domain in ('light', 'switch'):
|
|
||||||
# Focus on 1 entity
|
|
||||||
entity_id = self.hass.states.entity_ids(domain)[0]
|
|
||||||
|
|
||||||
self.hass.services.call(
|
|
||||||
domain, SERVICE_TURN_ON, {ATTR_ENTITY_ID: entity_id})
|
|
||||||
|
|
||||||
self.hass.pool.block_till_done()
|
|
||||||
|
|
||||||
self.assertEqual(STATE_ON, self.hass.states.get(entity_id).state)
|
|
||||||
|
|
||||||
self.hass.services.call(
|
|
||||||
domain, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: entity_id})
|
|
||||||
|
|
||||||
self.hass.pool.block_till_done()
|
|
||||||
|
|
||||||
self.assertEqual(STATE_OFF, self.hass.states.get(entity_id).state)
|
|
||||||
|
|
||||||
# Act on all
|
|
||||||
self.hass.services.call(domain, SERVICE_TURN_ON)
|
|
||||||
|
|
||||||
self.hass.pool.block_till_done()
|
|
||||||
|
|
||||||
for entity_id in self.hass.states.entity_ids(domain):
|
|
||||||
self.assertEqual(
|
|
||||||
STATE_ON, self.hass.states.get(entity_id).state)
|
|
||||||
|
|
||||||
self.hass.services.call(domain, SERVICE_TURN_OFF)
|
|
||||||
|
|
||||||
self.hass.pool.block_till_done()
|
|
||||||
|
|
||||||
for entity_id in self.hass.states.entity_ids(domain):
|
|
||||||
self.assertEqual(
|
|
||||||
STATE_OFF, self.hass.states.get(entity_id).state)
|
|
||||||
|
|
||||||
def test_if_demo_state_shows_by_default(self):
|
def test_if_demo_state_shows_by_default(self):
|
||||||
""" Test if demo state shows if we give no configuration. """
|
""" Test if demo state shows if we give no configuration. """
|
||||||
demo.setup(self.hass, {demo.DOMAIN: {}})
|
demo.setup(self.hass, {demo.DOMAIN: {}})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user