Fix PEP257 issues
This commit is contained in:
1 parent
d6eab03a61
commit
9838697d2b
120 files changed
+1447
-1297
No files matched your search
@@ -1,9 +1,4 @@
|
||||
"""
|
||||
tests.components.automation.test_time
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests time automation.
|
||||
"""
|
||||
"""The tests for the time automation."""
|
||||
from datetime import timedelta
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -17,9 +12,10 @@ from tests.common import fire_time_changed, get_test_home_assistant
|
||||
|
||||
|
||||
class TestAutomationTime(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 = []
|
||||
|
||||
@@ -29,10 +25,11 @@ class TestAutomationTime(unittest.TestCase):
|
||||
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_old_config_if_fires_when_hour_matches(self):
|
||||
"""Test for firing if hours are matching."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'platform': 'time',
|
||||
@@ -48,6 +45,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_old_config_if_fires_when_minute_matches(self):
|
||||
"""Test for firing if minutes are matching."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'platform': 'time',
|
||||
@@ -63,6 +61,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_old_config_if_fires_when_second_matches(self):
|
||||
"""Test for firing if seconds are matching."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'platform': 'time',
|
||||
@@ -78,6 +77,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_old_config_if_fires_when_all_matches(self):
|
||||
"""Test for firing if everything matches."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
CONF_PLATFORM: 'time',
|
||||
@@ -96,6 +96,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_old_config_if_action_before(self):
|
||||
"""Test for action before."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
CONF_PLATFORM: 'event',
|
||||
@@ -126,6 +127,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_old_config_if_action_after(self):
|
||||
"""Test for action after."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
CONF_PLATFORM: 'event',
|
||||
@@ -156,6 +158,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_old_config_if_action_one_weekday(self):
|
||||
"""Test for action with one weekday."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
CONF_PLATFORM: 'event',
|
||||
@@ -187,6 +190,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_old_config_if_action_list_weekday(self):
|
||||
"""Test for action with a list of weekdays."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
CONF_PLATFORM: 'event',
|
||||
@@ -226,6 +230,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(2, len(self.calls))
|
||||
|
||||
def test_if_fires_when_hour_matches(self):
|
||||
"""Test for firing if hour is matching."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -244,6 +249,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_when_minute_matches(self):
|
||||
"""Test for firing if minutes are matching."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -262,6 +268,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_when_second_matches(self):
|
||||
"""Test for firing if seconds are matching."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -280,6 +287,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_when_all_matches(self):
|
||||
"""Test for firing if everything matches."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -301,6 +309,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_periodic_seconds(self):
|
||||
"""Test for firing periodically every second."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -320,6 +329,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_periodic_minutes(self):
|
||||
"""Test for firing periodically every minute."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -339,6 +349,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_periodic_hours(self):
|
||||
"""Test for firing periodically every hour."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -358,6 +369,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_fires_using_after(self):
|
||||
"""Test for firing after."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -377,6 +389,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_not_working_if_no_values_in_conf_provided(self):
|
||||
"""Test for failure if no configuration."""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -396,8 +409,10 @@ class TestAutomationTime(unittest.TestCase):
|
||||
|
||||
@patch('homeassistant.components.automation.time._LOGGER.error')
|
||||
def test_if_not_fires_using_wrong_after(self, mock_error):
|
||||
""" YAML translates time values to total seconds. This should break the
|
||||
before rule. """
|
||||
"""YAML translates time values to total seconds.
|
||||
|
||||
This should break the before rule.
|
||||
"""
|
||||
self.assertTrue(automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -419,6 +434,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(2, mock_error.call_count)
|
||||
|
||||
def test_if_action_before(self):
|
||||
"""Test for if action before."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -453,6 +469,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_action_after(self):
|
||||
"""Test for if action after."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -487,6 +504,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_action_one_weekday(self):
|
||||
"""Test for if action with one weekday."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
@@ -522,6 +540,7 @@ class TestAutomationTime(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.calls))
|
||||
|
||||
def test_if_action_list_weekday(self):
|
||||
"""Test for action with a list of weekdays."""
|
||||
automation.setup(self.hass, {
|
||||
automation.DOMAIN: {
|
||||
'trigger': {
|
||||
|
||||
Reference in new issue
Block a user