Move counter component (#10332)
* Fix docstring * Add comment * Move counter to folder * Fix missing parts * Commit it when file is saved
This commit is contained in:
1 parent
5be6f8ff36
commit
a5d5f3f727
7 files changed
+68
-65
No files matched your search
@@ -0,0 +1 @@
|
||||
"""Tests for the counter component."""
|
||||
@@ -42,6 +42,47 @@ class TestCounter(unittest.TestCase):
|
||||
self.assertFalse(
|
||||
setup_component(self.hass, DOMAIN, {DOMAIN: cfg}))
|
||||
|
||||
def test_config_options(self):
|
||||
"""Test configuration options."""
|
||||
count_start = len(self.hass.states.entity_ids())
|
||||
|
||||
_LOGGER.debug('ENTITIES @ start: %s', self.hass.states.entity_ids())
|
||||
|
||||
config = {
|
||||
DOMAIN: {
|
||||
'test_1': {},
|
||||
'test_2': {
|
||||
CONF_NAME: 'Hello World',
|
||||
CONF_ICON: 'mdi:work',
|
||||
CONF_INITIAL: 10,
|
||||
CONF_STEP: 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert setup_component(self.hass, 'counter', config)
|
||||
self.hass.block_till_done()
|
||||
|
||||
_LOGGER.debug('ENTITIES: %s', self.hass.states.entity_ids())
|
||||
|
||||
self.assertEqual(count_start + 2, len(self.hass.states.entity_ids()))
|
||||
self.hass.block_till_done()
|
||||
|
||||
state_1 = self.hass.states.get('counter.test_1')
|
||||
state_2 = self.hass.states.get('counter.test_2')
|
||||
|
||||
self.assertIsNotNone(state_1)
|
||||
self.assertIsNotNone(state_2)
|
||||
|
||||
self.assertEqual(0, int(state_1.state))
|
||||
self.assertNotIn(ATTR_ICON, state_1.attributes)
|
||||
self.assertNotIn(ATTR_FRIENDLY_NAME, state_1.attributes)
|
||||
|
||||
self.assertEqual(10, int(state_2.state))
|
||||
self.assertEqual('Hello World',
|
||||
state_2.attributes.get(ATTR_FRIENDLY_NAME))
|
||||
self.assertEqual('mdi:work', state_2.attributes.get(ATTR_ICON))
|
||||
|
||||
def test_methods(self):
|
||||
"""Test increment, decrement, and reset methods."""
|
||||
config = {
|
||||
@@ -118,47 +159,6 @@ class TestCounter(unittest.TestCase):
|
||||
state = self.hass.states.get(entity_id)
|
||||
self.assertEqual(15, int(state.state))
|
||||
|
||||
def test_config_options(self):
|
||||
"""Test configuration options."""
|
||||
count_start = len(self.hass.states.entity_ids())
|
||||
|
||||
_LOGGER.debug('ENTITIES @ start: %s', self.hass.states.entity_ids())
|
||||
|
||||
config = {
|
||||
DOMAIN: {
|
||||
'test_1': {},
|
||||
'test_2': {
|
||||
CONF_NAME: 'Hello World',
|
||||
CONF_ICON: 'mdi:work',
|
||||
CONF_INITIAL: 10,
|
||||
CONF_STEP: 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert setup_component(self.hass, 'counter', config)
|
||||
self.hass.block_till_done()
|
||||
|
||||
_LOGGER.debug('ENTITIES: %s', self.hass.states.entity_ids())
|
||||
|
||||
self.assertEqual(count_start + 2, len(self.hass.states.entity_ids()))
|
||||
self.hass.block_till_done()
|
||||
|
||||
state_1 = self.hass.states.get('counter.test_1')
|
||||
state_2 = self.hass.states.get('counter.test_2')
|
||||
|
||||
self.assertIsNotNone(state_1)
|
||||
self.assertIsNotNone(state_2)
|
||||
|
||||
self.assertEqual(0, int(state_1.state))
|
||||
self.assertNotIn(ATTR_ICON, state_1.attributes)
|
||||
self.assertNotIn(ATTR_FRIENDLY_NAME, state_1.attributes)
|
||||
|
||||
self.assertEqual(10, int(state_2.state))
|
||||
self.assertEqual('Hello World',
|
||||
state_2.attributes.get(ATTR_FRIENDLY_NAME))
|
||||
self.assertEqual('mdi:work', state_2.attributes.get(ATTR_ICON))
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_initial_state_overrules_restore_state(hass):
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Test fan component plaforms."""
|
||||
"""Tests for fan platforms."""
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
Reference in new issue
Block a user