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.helpers.test_service
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Test service helpers.
|
||||
"""
|
||||
"""Test service helpers."""
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
|
@ -15,21 +10,21 @@ from tests.common import get_test_home_assistant, mock_service
|
|||
|
||||
|
||||
class TestServiceHelpers(unittest.TestCase):
|
||||
""" Tests the Home Assistant service helpers. """
|
||||
"""Test the Home Assistant service helpers."""
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
""" things to be run when tests are started. """
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.calls = mock_service(self.hass, 'test_domain', 'test_service')
|
||||
|
||||
service.HASS = self.hass
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
""" Stop down stuff we started. """
|
||||
"""Stop down everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_service(self):
|
||||
""" Test service registration decorator. """
|
||||
"""Test service registration decorator."""
|
||||
runs = []
|
||||
|
||||
decor = service.service('test', 'test')
|
||||
|
@ -40,6 +35,7 @@ class TestServiceHelpers(unittest.TestCase):
|
|||
self.assertEqual(1, len(runs))
|
||||
|
||||
def test_split_entity_string(self):
|
||||
"""Test splitting of entity string."""
|
||||
service.call_from_config(self.hass, {
|
||||
'service': 'test_domain.test_service',
|
||||
'entity_id': 'hello.world, sensor.beer'
|
||||
|
@ -49,6 +45,7 @@ class TestServiceHelpers(unittest.TestCase):
|
|||
self.calls[-1].data.get('entity_id'))
|
||||
|
||||
def test_not_mutate_input(self):
|
||||
"""Test for immutable input."""
|
||||
orig = {
|
||||
'service': 'test_domain.test_service',
|
||||
'entity_id': 'hello.world, sensor.beer',
|
||||
|
@ -68,6 +65,7 @@ class TestServiceHelpers(unittest.TestCase):
|
|||
|
||||
@patch('homeassistant.helpers.service._LOGGER.error')
|
||||
def test_fail_silently_if_no_service(self, mock_log):
|
||||
"""Test failling if service is missing."""
|
||||
service.call_from_config(self.hass, None)
|
||||
self.assertEqual(1, mock_log.call_count)
|
||||
|
||||
|
@ -80,7 +78,7 @@ class TestServiceHelpers(unittest.TestCase):
|
|||
self.assertEqual(3, mock_log.call_count)
|
||||
|
||||
def test_extract_entity_ids(self):
|
||||
""" Test extract_entity_ids method. """
|
||||
"""Test extract_entity_ids method."""
|
||||
self.hass.states.set('light.Bowl', STATE_ON)
|
||||
self.hass.states.set('light.Ceiling', STATE_OFF)
|
||||
self.hass.states.set('light.Kitchen', STATE_OFF)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue