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.components.automation.test_numeric_state
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests numeric state automation.
|
||||
"""
|
||||
"""The tests for numeric state automation."""
|
||||
import unittest
|
||||
|
||||
import homeassistant.components.automation as automation
|
||||
|
@ -12,22 +7,25 @@ from tests.common import get_test_home_assistant
|
|||
|
||||
|
||||
class TestAutomationNumericState(unittest.TestCase):
|
||||
""" Test the event automation. """
|
||||
"""Test the event automation."""
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.calls = []
|
||||
|
||||
def record_call(service):
|
||||
"""Helper to record calls."""
|
||||
self.calls.append(service)
|
||||
|
||||
self.hass.services.register('test', 'automation', record_call)
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
""" Stop down stuff we started. """
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_if_fires_on_entity_change_below(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -46,6 +44,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_over_to_below(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.hass.states.set('test.entity', 11)
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
|
@ -68,6 +67,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_not_fires_on_entity_change_below_to_below(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.hass.states.set('test.entity', 9)
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
|
@ -90,6 +90,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_above(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -108,6 +109,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_below_to_above(self):
|
||||
""""Test the firing with changed entity."""
|
||||
# set initial state
|
||||
self.hass.states.set('test.entity', 9)
|
||||
self.hass.pool.block_till_done()
|
||||
|
@ -131,6 +133,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_not_fires_on_entity_change_above_to_above(self):
|
||||
""""Test the firing with changed entity."""
|
||||
# set initial state
|
||||
self.hass.states.set('test.entity', 11)
|
||||
self.hass.pool.block_till_done()
|
||||
|
@ -154,6 +157,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_below_range(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -173,6 +177,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_below_above_range(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -192,6 +197,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_over_to_below_range(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.hass.states.set('test.entity', 11)
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
|
@ -215,6 +221,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_over_to_below_above_range(self):
|
||||
""""Test the firing with changed entity."""
|
||||
self.hass.states.set('test.entity', 11)
|
||||
self.hass.pool.block_till_done()
|
||||
|
||||
|
@ -238,6 +245,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_not_fires_if_entity_not_match(self):
|
||||
""""Test if not fired with non matching entity."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -255,6 +263,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_fires_on_entity_change_below_with_attribute(self):
|
||||
""""Test attributes change."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -273,6 +282,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_not_fires_on_entity_change_not_below_with_attribute(self):
|
||||
""""Test attributes."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -291,6 +301,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_fires_on_attribute_change_with_attribute_below(self):
|
||||
""""Test attributes change."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -310,6 +321,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_not_fires_on_attribute_change_with_attribute_not_below(self):
|
||||
""""Test attributes change."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -329,6 +341,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_not_fires_on_entity_change_with_attribute_below(self):
|
||||
""""Test attributes change."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -348,6 +361,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_not_fires_on_entity_change_with_not_attribute_below(self):
|
||||
""""Test attributes change."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -367,6 +381,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_fires_on_attr_change_with_attribute_below_and_multiple_attr(self):
|
||||
""""Test attributes change."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -387,6 +402,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_template_list(self):
|
||||
""""Test template list."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -408,6 +424,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_template_string(self):
|
||||
""""Test template string."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -429,6 +446,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_not_fires_on_attr_change_with_attr_not_below_multiple_attr(self):
|
||||
""""Test if not fired changed attributes."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
@ -449,6 +467,7 @@ class TestAutomationNumericState(unittest.TestCase):
|
|||
self.assertEqual(0, len(self.calls))
|
||||
|
||||
def test_if_action(self):
|
||||
""""Test if action."""
|
||||
entity_id = 'domain.test_entity'
|
||||
test_state = 10
|
||||
automation.setup(self.hass, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue