Fix PEP257 issues
This commit is contained in:
parent
d6eab03a61
commit
9838697d2b
120 changed files with 1447 additions and 1297 deletions
|
@ -1,9 +1,4 @@
|
|||
"""
|
||||
tests.test_component_group
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests the group compoments.
|
||||
"""
|
||||
"""The tests for the Group components."""
|
||||
# pylint: disable=protected-access,too-many-public-methods
|
||||
import unittest
|
||||
|
||||
|
@ -16,18 +11,18 @@ from tests.common import get_test_home_assistant
|
|||
|
||||
|
||||
class TestComponentsGroup(unittest.TestCase):
|
||||
""" Tests homeassistant.components.group module. """
|
||||
"""Test Group component."""
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
""" Init needed objects. """
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
""" Stop down stuff we started. """
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_setup_group_with_mixed_groupable_states(self):
|
||||
""" Try to setup a group with mixed groupable states """
|
||||
"""Try to setup a group with mixed groupable states."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('device_tracker.Paulus', STATE_HOME)
|
||||
group.Group(
|
||||
|
@ -40,7 +35,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
group.ENTITY_ID_FORMAT.format('person_and_light')).state)
|
||||
|
||||
def test_setup_group_with_a_non_existing_state(self):
|
||||
""" Try to setup a group with a non existing state """
|
||||
"""Try to setup a group with a non existing state."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
|
||||
grp = group.Group(
|
||||
|
@ -50,6 +45,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertEqual(STATE_ON, grp.state)
|
||||
|
||||
def test_setup_group_with_non_groupable_states(self):
|
||||
"""Test setup with groups which are not groupable."""
|
||||
self.hass.states.set('cast.living_room', "Plex")
|
||||
self.hass.states.set('cast.bedroom', "Netflix")
|
||||
|
||||
|
@ -60,13 +56,13 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertEqual(STATE_UNKNOWN, grp.state)
|
||||
|
||||
def test_setup_empty_group(self):
|
||||
""" Try to setup an empty group. """
|
||||
"""Try to setup an empty group."""
|
||||
grp = group.Group(self.hass, 'nothing', [])
|
||||
|
||||
self.assertEqual(STATE_UNKNOWN, grp.state)
|
||||
|
||||
def test_monitor_group(self):
|
||||
""" Test if the group keeps track of states. """
|
||||
"""Test if the group keeps track of states."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -80,9 +76,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertTrue(group_state.attributes.get(group.ATTR_AUTO))
|
||||
|
||||
def test_group_turns_off_if_all_off(self):
|
||||
"""
|
||||
Test if the group turns off if the last device that was on turns off.
|
||||
"""
|
||||
"""Test if turn off if the last device that was on turns off."""
|
||||
self.hass.states.set('light.Bowl', STATE_OFF)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -94,9 +88,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertEqual(STATE_OFF, group_state.state)
|
||||
|
||||
def test_group_turns_on_if_all_are_off_and_one_turns_on(self):
|
||||
"""
|
||||
Test if group turns on if all devices were turned off and one turns on.
|
||||
"""
|
||||
"""Test if turn on if all devices were turned off and one turns on."""
|
||||
self.hass.states.set('light.Bowl', STATE_OFF)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -110,7 +102,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertEqual(STATE_ON, group_state.state)
|
||||
|
||||
def test_is_on(self):
|
||||
""" Test is_on method. """
|
||||
"""Test is_on method."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -125,7 +117,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertFalse(group.is_on(self.hass, 'non.existing'))
|
||||
|
||||
def test_expand_entity_ids(self):
|
||||
""" Test expand_entity_ids method. """
|
||||
"""Test expand_entity_ids method."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -136,7 +128,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.hass, [test_group.entity_id])))
|
||||
|
||||
def test_expand_entity_ids_does_not_return_duplicates(self):
|
||||
""" Test that expand_entity_ids does not return duplicates. """
|
||||
"""Test that expand_entity_ids does not return duplicates."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -153,11 +145,11 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.hass, ['light.bowl', test_group.entity_id])))
|
||||
|
||||
def test_expand_entity_ids_ignores_non_strings(self):
|
||||
""" Test that non string elements in lists are ignored. """
|
||||
"""Test that non string elements in lists are ignored."""
|
||||
self.assertEqual([], group.expand_entity_ids(self.hass, [5, True]))
|
||||
|
||||
def test_get_entity_ids(self):
|
||||
""" Test get_entity_ids method. """
|
||||
"""Test get_entity_ids method."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -168,7 +160,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
sorted(group.get_entity_ids(self.hass, test_group.entity_id)))
|
||||
|
||||
def test_get_entity_ids_with_domain_filter(self):
|
||||
""" Test if get_entity_ids works with a domain_filter. """
|
||||
"""Test if get_entity_ids works with a domain_filter."""
|
||||
self.hass.states.set('switch.AC', STATE_OFF)
|
||||
|
||||
mixed_group = group.Group(
|
||||
|
@ -180,16 +172,19 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.hass, mixed_group.entity_id, domain_filter="switch"))
|
||||
|
||||
def test_get_entity_ids_with_non_existing_group_name(self):
|
||||
""" Tests get_entity_ids with a non existing group. """
|
||||
"""Test get_entity_ids with a non existing group."""
|
||||
self.assertEqual([], group.get_entity_ids(self.hass, 'non_existing'))
|
||||
|
||||
def test_get_entity_ids_with_non_group_state(self):
|
||||
""" Tests get_entity_ids with a non group state. """
|
||||
"""Test get_entity_ids with a non group state."""
|
||||
self.assertEqual([], group.get_entity_ids(self.hass, 'switch.AC'))
|
||||
|
||||
def test_group_being_init_before_first_tracked_state_is_set_to_on(self):
|
||||
""" Test if the group turns on if no states existed and now a state it is
|
||||
tracking is being added as ON. """
|
||||
"""Test if the groups turn on.
|
||||
|
||||
If no states existed and now a state it is tracking is being added
|
||||
as ON.
|
||||
"""
|
||||
test_group = group.Group(
|
||||
self.hass, 'test group', ['light.not_there_1'])
|
||||
|
||||
|
@ -201,8 +196,11 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertEqual(STATE_ON, group_state.state)
|
||||
|
||||
def test_group_being_init_before_first_tracked_state_is_set_to_off(self):
|
||||
""" Test if the group turns off if no states existed and now a state it is
|
||||
tracking is being added as OFF. """
|
||||
"""Test if the group turns off.
|
||||
|
||||
If no states existed and now a state it is tracking is being added
|
||||
as OFF.
|
||||
"""
|
||||
test_group = group.Group(
|
||||
self.hass, 'test group', ['light.not_there_1'])
|
||||
|
||||
|
@ -214,7 +212,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertEqual(STATE_OFF, group_state.state)
|
||||
|
||||
def test_setup(self):
|
||||
""" Test setup method. """
|
||||
"""Test setup method."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
@ -256,13 +254,14 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
self.assertIsNone(group_state.attributes.get(ATTR_HIDDEN))
|
||||
|
||||
def test_groups_get_unique_names(self):
|
||||
""" Two groups with same name should both have a unique entity id. """
|
||||
"""Two groups with same name should both have a unique entity id."""
|
||||
grp1 = group.Group(self.hass, 'Je suis Charlie')
|
||||
grp2 = group.Group(self.hass, 'Je suis Charlie')
|
||||
|
||||
self.assertNotEqual(grp1.entity_id, grp2.entity_id)
|
||||
|
||||
def test_expand_entity_ids_expands_nested_groups(self):
|
||||
"""Test if entity ids epands to nested groups."""
|
||||
group.Group(self.hass, 'light', ['light.test_1', 'light.test_2'])
|
||||
group.Group(self.hass, 'switch', ['switch.test_1', 'switch.test_2'])
|
||||
group.Group(self.hass, 'group_of_groups', ['group.light',
|
||||
|
@ -274,6 +273,7 @@ class TestComponentsGroup(unittest.TestCase):
|
|||
['group.group_of_groups'])))
|
||||
|
||||
def test_set_assumed_state_based_on_tracked(self):
|
||||
"""Test assumed state."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
test_group = group.Group(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue