Fix PEP257 issues
This commit is contained in:
1 parent
d6eab03a61
commit
9838697d2b
120 files changed
+1447
-1297
No files matched your search
@@ -0,0 +1 @@
|
||||
"""The tests for Light platforms."""
|
||||
@@ -1,9 +1,4 @@
|
||||
"""
|
||||
tests.components.test_init
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests light component.
|
||||
"""
|
||||
"""The tests for the Light component."""
|
||||
# pylint: disable=too-many-public-methods,protected-access
|
||||
import unittest
|
||||
import os
|
||||
@@ -18,13 +13,14 @@ from tests.common import mock_service, get_test_home_assistant
|
||||
|
||||
|
||||
class TestLight(unittest.TestCase):
|
||||
""" Test the light module. """
|
||||
"""Test the light module."""
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
"""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()
|
||||
|
||||
user_light_file = self.hass.config.path(light.LIGHT_PROFILES_FILE)
|
||||
@@ -33,7 +29,7 @@ class TestLight(unittest.TestCase):
|
||||
os.remove(user_light_file)
|
||||
|
||||
def test_methods(self):
|
||||
""" Test if methods call the services as expected. """
|
||||
"""Test if methods call the services as expected."""
|
||||
# Test is_on
|
||||
self.hass.states.set('light.test', STATE_ON)
|
||||
self.assertTrue(light.is_on(self.hass, 'light.test'))
|
||||
@@ -111,7 +107,7 @@ class TestLight(unittest.TestCase):
|
||||
self.assertEqual('transition_val', call.data[light.ATTR_TRANSITION])
|
||||
|
||||
def test_services(self):
|
||||
""" Test the provided services. """
|
||||
"""Test the provided services."""
|
||||
platform = loader.get_component('light.test')
|
||||
|
||||
platform.init()
|
||||
@@ -245,7 +241,7 @@ class TestLight(unittest.TestCase):
|
||||
data)
|
||||
|
||||
def test_broken_light_profiles(self):
|
||||
""" Test light profiles. """
|
||||
"""Test light profiles."""
|
||||
platform = loader.get_component('light.test')
|
||||
platform.init()
|
||||
|
||||
@@ -261,7 +257,7 @@ class TestLight(unittest.TestCase):
|
||||
))
|
||||
|
||||
def test_light_profiles(self):
|
||||
""" Test light profiles. """
|
||||
"""Test light profiles."""
|
||||
platform = loader.get_component('light.test')
|
||||
platform.init()
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
"""
|
||||
tests.components.light.test_mqtt
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
"""The tests for the MQTT light platform.
|
||||
|
||||
Tests mqtt light.
|
||||
|
||||
config for RGB Version with brightness:
|
||||
Configuration for RGB Version with brightness:
|
||||
|
||||
light:
|
||||
platform: mqtt
|
||||
@@ -59,7 +55,6 @@ light:
|
||||
qos: 0
|
||||
payload_on: "on"
|
||||
payload_off: "off"
|
||||
|
||||
"""
|
||||
import unittest
|
||||
|
||||
@@ -70,17 +65,19 @@ from tests.common import (
|
||||
|
||||
|
||||
class TestLightMQTT(unittest.TestCase):
|
||||
""" Test the MQTT light. """
|
||||
"""Test the MQTT light."""
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant()
|
||||
self.mock_publish = mock_mqtt_component(self.hass)
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
""" Stop down stuff we started. """
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
def test_fail_setup_if_no_command_topic(self):
|
||||
"""Test if command fails with command topic."""
|
||||
self.assertTrue(light.setup(self.hass, {
|
||||
'light': {
|
||||
'platform': 'mqtt',
|
||||
@@ -90,6 +87,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
self.assertIsNone(self.hass.states.get('light.test'))
|
||||
|
||||
def test_no_color_or_brightness_if_no_topics(self):
|
||||
"""Test if there is no color and brightness if no topic."""
|
||||
self.assertTrue(light.setup(self.hass, {
|
||||
'light': {
|
||||
'platform': 'mqtt',
|
||||
@@ -113,6 +111,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
self.assertIsNone(state.attributes.get('brightness'))
|
||||
|
||||
def test_controlling_state_via_topic(self):
|
||||
"""Test the controlling of the state via topic."""
|
||||
self.assertTrue(light.setup(self.hass, {
|
||||
'light': {
|
||||
'platform': 'mqtt',
|
||||
@@ -172,6 +171,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
light_state.attributes.get('rgb_color'))
|
||||
|
||||
def test_controlling_scale(self):
|
||||
"""Test the controlling scale."""
|
||||
self.assertTrue(light.setup(self.hass, {
|
||||
'light': {
|
||||
'platform': 'mqtt',
|
||||
@@ -217,6 +217,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
light_state.attributes['brightness'])
|
||||
|
||||
def test_controlling_state_via_topic_with_templates(self):
|
||||
"""Test the setting og the state with a template."""
|
||||
self.assertTrue(light.setup(self.hass, {
|
||||
'light': {
|
||||
'platform': 'mqtt',
|
||||
@@ -250,6 +251,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
self.assertEqual([1, 2, 3], state.attributes.get('rgb_color'))
|
||||
|
||||
def test_sending_mqtt_commands_and_optimistic(self):
|
||||
"""Test the sending of command in optimistic mode."""
|
||||
self.assertTrue(light.setup(self.hass, {
|
||||
'light': {
|
||||
'platform': 'mqtt',
|
||||
@@ -307,6 +309,7 @@ class TestLightMQTT(unittest.TestCase):
|
||||
self.assertEqual(50, state.attributes['brightness'])
|
||||
|
||||
def test_show_brightness_if_only_command_topic(self):
|
||||
"""Test the brightness if only a command topic is present."""
|
||||
self.assertTrue(light.setup(self.hass, {
|
||||
'light': {
|
||||
'platform': 'mqtt',
|
||||
|
||||
@@ -1,10 +1,4 @@
|
||||
"""
|
||||
tests.components.light.test_rfxtrx
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Tests Rfxtrx light.
|
||||
"""
|
||||
|
||||
"""The tests for the Rfxtrx light platform."""
|
||||
import unittest
|
||||
|
||||
from homeassistant.components import rfxtrx as rfxtrx_core
|
||||
@@ -18,25 +12,25 @@ from tests.common import get_test_home_assistant
|
||||
|
||||
@pytest.mark.skipif(True, reason='Does not clean up properly, takes 100% CPU')
|
||||
class TestLightRfxtrx(unittest.TestCase):
|
||||
""" Test the Rfxtrx light. """
|
||||
"""Test the Rfxtrx light platform."""
|
||||
|
||||
def setUp(self):
|
||||
""" setup hass """
|
||||
"""Setup things to be run when tests are started."""
|
||||
self.hass = get_test_home_assistant(0)
|
||||
|
||||
def tearDown(self):
|
||||
""" Stop down stuff we started. """
|
||||
"""Stop everything that was started."""
|
||||
rfxtrx_core.RECEIVED_EVT_SUBSCRIBERS = []
|
||||
rfxtrx_core.RFX_DEVICES = {}
|
||||
self.hass.stop()
|
||||
|
||||
def test_default_config(self):
|
||||
""" Test with 0 lights """
|
||||
"""Test with 0 lights."""
|
||||
config = {'devices': {}}
|
||||
devices = []
|
||||
|
||||
def add_dev_callback(devs):
|
||||
""" callback to add device """
|
||||
"""Add a callback to add devices."""
|
||||
for dev in devs:
|
||||
devices.append(dev)
|
||||
|
||||
@@ -44,7 +38,7 @@ class TestLightRfxtrx(unittest.TestCase):
|
||||
self.assertEqual(0, len(devices))
|
||||
|
||||
def test_one_sensor(self):
|
||||
""" Test with 1 light """
|
||||
"""Test with 1 light."""
|
||||
config = {'devices':
|
||||
{'123efab1': {
|
||||
'name': 'Test',
|
||||
@@ -56,7 +50,7 @@ class TestLightRfxtrx(unittest.TestCase):
|
||||
devices = []
|
||||
|
||||
def add_dev_callback(devs):
|
||||
""" callback to add device """
|
||||
"""Add a callback to add devices."""
|
||||
for dev in devs:
|
||||
devices.append(dev)
|
||||
|
||||
@@ -104,7 +98,7 @@ class TestLightRfxtrx(unittest.TestCase):
|
||||
self.assertEqual(entity.brightness, 255)
|
||||
|
||||
def test_several_lights(self):
|
||||
""" Test with 3 lights """
|
||||
"""Test with 3 lights."""
|
||||
config = {'signal_repetitions': 3,
|
||||
'devices':
|
||||
{'123efab1': {
|
||||
@@ -119,7 +113,7 @@ class TestLightRfxtrx(unittest.TestCase):
|
||||
devices = []
|
||||
|
||||
def add_dev_callback(devs):
|
||||
""" callback to add device """
|
||||
"""Add a callback to add devices."""
|
||||
for dev in devs:
|
||||
devices.append(dev)
|
||||
|
||||
@@ -145,12 +139,12 @@ class TestLightRfxtrx(unittest.TestCase):
|
||||
self.assertEqual(3, device_num)
|
||||
|
||||
def test_discover_light(self):
|
||||
""" Test with discover of light """
|
||||
"""Test with discovery of lights."""
|
||||
config = {'automatic_add': True, 'devices': {}}
|
||||
devices = []
|
||||
|
||||
def add_dev_callback(devs):
|
||||
""" callback to add device """
|
||||
"""Add a callback to add devices."""
|
||||
for dev in devs:
|
||||
devices.append(dev)
|
||||
|
||||
@@ -209,12 +203,12 @@ class TestLightRfxtrx(unittest.TestCase):
|
||||
self.assertEqual(2, len(devices))
|
||||
|
||||
def test_discover_light_noautoadd(self):
|
||||
""" Test with discover of light when auto add is False """
|
||||
"""Test with discover of light when auto add is False."""
|
||||
config = {'automatic_add': False, 'devices': {}}
|
||||
devices = []
|
||||
|
||||
def add_dev_callback(devs):
|
||||
""" callback to add device """
|
||||
"""Add a callback to add devices."""
|
||||
for dev in devs:
|
||||
devices.append(dev)
|
||||
|
||||
@@ -250,14 +244,14 @@ class TestLightRfxtrx(unittest.TestCase):
|
||||
self.assertEqual(0, len(rfxtrx_core.RFX_DEVICES))
|
||||
self.assertEqual(0, len(devices))
|
||||
|
||||
# trying to add a sensor
|
||||
# Trying to add a sensor
|
||||
event = rfxtrx_core.get_rfx_object('0a52085e070100b31b0279')
|
||||
event.data = bytearray(b'\nR\x08^\x07\x01\x00\xb3\x1b\x02y')
|
||||
rfxtrx_core.RECEIVED_EVT_SUBSCRIBERS[0](event)
|
||||
self.assertEqual(0, len(rfxtrx_core.RFX_DEVICES))
|
||||
self.assertEqual(0, len(devices))
|
||||
|
||||
# trying to add a switch
|
||||
# Trying to add a switch
|
||||
event = rfxtrx_core.get_rfx_object('0b1100100118cdea02010f70')
|
||||
event.data = bytearray([0x0b, 0x11, 0x00, 0x10, 0x01, 0x18,
|
||||
0xcd, 0xea, 0x01, 0x01, 0x0f, 0x70])
|
||||
|
||||
Reference in new issue
Block a user