diff --git a/tests/components/automation/test_event.py b/tests/components/automation/test_event.py index 22158402ff9..a81e4200f48 100644 --- a/tests/components/automation/test_event.py +++ b/tests/components/automation/test_event.py @@ -8,10 +8,11 @@ import homeassistant.components.automation as automation from tests.common import get_test_home_assistant +# pylint: disable=invalid-name class TestAutomationEvent(unittest.TestCase): """Test the event automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -24,7 +25,7 @@ class TestAutomationEvent(unittest.TestCase): self.hass.services.register('test', 'automation', record_call) - def tearDown(self): # pylint: disable=invalid-name + def tearDown(self): """"Stop everything that was started.""" self.hass.stop() diff --git a/tests/components/automation/test_init.py b/tests/components/automation/test_init.py index e06984e9f7d..39df4af719d 100644 --- a/tests/components/automation/test_init.py +++ b/tests/components/automation/test_init.py @@ -14,11 +14,10 @@ from tests.common import get_test_home_assistant, assert_setup_component, \ fire_time_changed +# pylint: disable=invalid-name class TestAutomation(unittest.TestCase): """Test the event automation.""" - # pylint: disable=invalid-name - def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() @@ -27,12 +26,12 @@ class TestAutomation(unittest.TestCase): @callback def record_call(service): - """Record call.""" + """Helper to record calls.""" self.calls.append(service) self.hass.services.register('test', 'automation', record_call) - def tearDown(self): # pylint: disable=invalid-name + def tearDown(self): """Stop everything that was started.""" self.hass.stop() @@ -438,20 +437,20 @@ class TestAutomation(unittest.TestCase): @patch('homeassistant.config.load_yaml_config_file', autospec=True, return_value={ - automation.DOMAIN: { - 'alias': 'bye', - 'trigger': { - 'platform': 'event', - 'event_type': 'test_event2', - }, - 'action': { - 'service': 'test.automation', - 'data_template': { - 'event': '{{ trigger.event.event_type }}' - } - } - } - }) + automation.DOMAIN: { + 'alias': 'bye', + 'trigger': { + 'platform': 'event', + 'event_type': 'test_event2', + }, + 'action': { + 'service': 'test.automation', + 'data_template': { + 'event': '{{ trigger.event.event_type }}' + } + } + } + }) def test_reload_config_service(self, mock_load_yaml): """Test the reload config service.""" assert setup_component(self.hass, automation.DOMAIN, { diff --git a/tests/components/automation/test_mqtt.py b/tests/components/automation/test_mqtt.py index 4e58dc7a442..e704b9b2d64 100644 --- a/tests/components/automation/test_mqtt.py +++ b/tests/components/automation/test_mqtt.py @@ -8,10 +8,11 @@ from tests.common import ( mock_mqtt_component, fire_mqtt_message, get_test_home_assistant) +# pylint: disable=invalid-name class TestAutomationMQTT(unittest.TestCase): """Test the event automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -20,11 +21,12 @@ class TestAutomationMQTT(unittest.TestCase): @callback 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 + def tearDown(self): """Stop everything that was started.""" self.hass.stop() diff --git a/tests/components/automation/test_numeric_state.py b/tests/components/automation/test_numeric_state.py index d0aedd87f46..c7db55726eb 100644 --- a/tests/components/automation/test_numeric_state.py +++ b/tests/components/automation/test_numeric_state.py @@ -8,10 +8,11 @@ import homeassistant.components.automation as automation from tests.common import get_test_home_assistant +# pylint: disable=invalid-name class TestAutomationNumericState(unittest.TestCase): """Test the event automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -451,8 +452,8 @@ class TestAutomationNumericState(unittest.TestCase): 'service': 'test.automation', 'data_template': { 'some': '{{ trigger.%s }}' % '}} - {{ trigger.'.join(( - 'platform', 'entity_id', 'below', 'above', - 'from_state.state', 'to_state.state')) + 'platform', 'entity_id', 'below', 'above', + 'from_state.state', 'to_state.state')) }, } } diff --git a/tests/components/automation/test_state.py b/tests/components/automation/test_state.py index 3b4e4486112..3f54c876c5f 100644 --- a/tests/components/automation/test_state.py +++ b/tests/components/automation/test_state.py @@ -1,6 +1,7 @@ """The test for state automation.""" -import unittest from datetime import timedelta + +import unittest from unittest.mock import patch from homeassistant.core import callback @@ -12,10 +13,11 @@ from tests.common import ( fire_time_changed, get_test_home_assistant, assert_setup_component) +# pylint: disable=invalid-name class TestAutomationState(unittest.TestCase): """Test the event automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -24,11 +26,12 @@ class TestAutomationState(unittest.TestCase): @callback def record_call(service): + """Call recorder.""" self.calls.append(service) self.hass.services.register('test', 'automation', record_call) - def tearDown(self): # pylint: disable=invalid-name + def tearDown(self): """Stop everything that was started.""" self.hass.stop() @@ -47,9 +50,9 @@ class TestAutomationState(unittest.TestCase): 'service': 'test.automation', 'data_template': { 'some': '{{ trigger.%s }}' % '}} - {{ trigger.'.join(( - 'platform', 'entity_id', - 'from_state.state', 'to_state.state', - 'for')) + 'platform', 'entity_id', + 'from_state.state', 'to_state.state', + 'for')) }, } } diff --git a/tests/components/automation/test_sun.py b/tests/components/automation/test_sun.py index 475a8f55259..582533d8476 100644 --- a/tests/components/automation/test_sun.py +++ b/tests/components/automation/test_sun.py @@ -1,5 +1,6 @@ """The tests for the sun automation.""" from datetime import datetime + import unittest from unittest.mock import patch @@ -12,10 +13,11 @@ import homeassistant.util.dt as dt_util from tests.common import fire_time_changed, get_test_home_assistant +# pylint: disable=invalid-name class TestAutomationSun(unittest.TestCase): """Test the sun automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -25,11 +27,12 @@ class TestAutomationSun(unittest.TestCase): @callback def record_call(service): + """Call recorder.""" self.calls.append(service) self.hass.services.register('test', 'automation', record_call) - def tearDown(self): # pylint: disable=invalid-name + def tearDown(self): """Stop everything that was started.""" self.hass.stop() diff --git a/tests/components/automation/test_template.py b/tests/components/automation/test_template.py index 1430d303140..7de2954a270 100644 --- a/tests/components/automation/test_template.py +++ b/tests/components/automation/test_template.py @@ -8,10 +8,11 @@ import homeassistant.components.automation as automation from tests.common import get_test_home_assistant, assert_setup_component +# pylint: disable=invalid-name class TestAutomationTemplate(unittest.TestCase): """Test the event automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -20,12 +21,12 @@ class TestAutomationTemplate(unittest.TestCase): @callback def record_call(service): - """helper for recording calls.""" + """Helper to record calls.""" self.calls.append(service) self.hass.services.register('test', 'automation', record_call) - def tearDown(self): # pylint: disable=invalid-name + def tearDown(self): """Stop everything that was started.""" self.hass.stop() diff --git a/tests/components/automation/test_time.py b/tests/components/automation/test_time.py index ff2d20145d9..10e7910adcb 100644 --- a/tests/components/automation/test_time.py +++ b/tests/components/automation/test_time.py @@ -12,10 +12,11 @@ from tests.common import ( fire_time_changed, get_test_home_assistant, assert_setup_component) +# pylint: disable=invalid-name class TestAutomationTime(unittest.TestCase): """Test the event automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -23,11 +24,12 @@ class TestAutomationTime(unittest.TestCase): @callback 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 + def tearDown(self): """Stop everything that was started.""" self.hass.stop() diff --git a/tests/components/automation/test_zone.py b/tests/components/automation/test_zone.py index d81cb8f0bd5..72a79faa828 100644 --- a/tests/components/automation/test_zone.py +++ b/tests/components/automation/test_zone.py @@ -8,10 +8,11 @@ from homeassistant.components import automation, zone from tests.common import get_test_home_assistant +# pylint: disable=invalid-name class TestAutomationZone(unittest.TestCase): """Test the event automation.""" - def setUp(self): # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.components.append('group') @@ -28,11 +29,12 @@ class TestAutomationZone(unittest.TestCase): @callback 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 + def tearDown(self): """Stop everything that was started.""" self.hass.stop() @@ -56,9 +58,9 @@ class TestAutomationZone(unittest.TestCase): 'service': 'test.automation', 'data_template': { 'some': '{{ trigger.%s }}' % '}} - {{ trigger.'.join(( - 'platform', 'entity_id', - 'from_state.state', 'to_state.state', - 'zone.name')) + 'platform', 'entity_id', + 'from_state.state', 'to_state.state', + 'zone.name')) }, } diff --git a/tests/components/binary_sensor/test_nx584.py b/tests/components/binary_sensor/test_nx584.py index 6ed2ae476f3..5481bbc9198 100644 --- a/tests/components/binary_sensor/test_nx584.py +++ b/tests/components/binary_sensor/test_nx584.py @@ -179,6 +179,7 @@ class TestNX584Watcher(unittest.TestCase): @mock.patch.object(watcher, '_process_zone_event') def run(fake_process): + """Run a fake process.""" fake_process.side_effect = StopMe self.assertRaises(StopMe, watcher._run) self.assertEqual(fake_process.call_count, 1) @@ -193,6 +194,7 @@ class TestNX584Watcher(unittest.TestCase): empty_me = [1, 2] def fake_run(): + """Fake runner.""" if empty_me: empty_me.pop() raise requests.exceptions.ConnectionError() diff --git a/tests/components/camera/test_uvc.py b/tests/components/camera/test_uvc.py index 41b272c15eb..f5cb0992ec0 100644 --- a/tests/components/camera/test_uvc.py +++ b/tests/components/camera/test_uvc.py @@ -121,7 +121,7 @@ class TestUVCSetup(unittest.TestCase): @mock.patch.object(uvc, 'UnifiVideoCamera') def test_setup_incomplete_config(self, mock_uvc): - """"Test the setup with incomplete configuration.""" + """Test the setup with incomplete configuration.""" assert setup_component( self.hass, 'camera', {'platform': 'uvc', 'nvr': 'foo'}) assert not mock_uvc.called @@ -135,7 +135,7 @@ class TestUVCSetup(unittest.TestCase): @mock.patch.object(uvc, 'UnifiVideoCamera') @mock.patch('uvcclient.nvr.UVCRemote') def test_setup_nvr_errors(self, mock_remote, mock_uvc): - """"Test for NVR errors.""" + """Test for NVR errors.""" errors = [nvr.NotAuthorized, nvr.NvrError, requests.exceptions.ConnectionError] config = { @@ -223,6 +223,7 @@ class TestUVC(unittest.TestCase): responses = [0] def fake_login(*a): + """Fake login.""" try: responses.pop(0) raise socket.error @@ -277,6 +278,7 @@ class TestUVC(unittest.TestCase): responses = [0] def fake_snapshot(): + """Fake snapshot.""" try: responses.pop() raise camera.CameraAuthError() diff --git a/tests/components/climate/test_demo.py b/tests/components/climate/test_demo.py index 04fc2e33247..518e4ca2c81 100644 --- a/tests/components/climate/test_demo.py +++ b/tests/components/climate/test_demo.py @@ -32,7 +32,7 @@ class TestDemoClimate(unittest.TestCase): self.hass.stop() def test_setup_params(self): - """Test the inititial parameters.""" + """Test the initial parameters.""" state = self.hass.states.get(ENTITY_CLIMATE) self.assertEqual(21, state.attributes.get('temperature')) self.assertEqual('on', state.attributes.get('away_mode')) @@ -93,8 +93,7 @@ class TestDemoClimate(unittest.TestCase): self.assertEqual(25.0, state.attributes.get('target_temp_high')) def test_set_target_temp_range_bad_attr(self): - """Test setting the target temperature range without required - attribute.""" + """Test setting the target temperature range without attribute.""" state = self.hass.states.get(ENTITY_ECOBEE) self.assertEqual(None, state.attributes.get('temperature')) self.assertEqual(21.0, state.attributes.get('target_temp_low')) @@ -163,8 +162,10 @@ class TestDemoClimate(unittest.TestCase): self.assertEqual("Auto", state.attributes.get('swing_mode')) def test_set_operation_bad_attr_and_state(self): - """Test setting operation mode without required attribute, and - check the state.""" + """Test setting operation mode without required attribute. + + Also check the state. + """ state = self.hass.states.get(ENTITY_CLIMATE) self.assertEqual("cool", state.attributes.get('operation_mode')) self.assertEqual("cool", state.state) diff --git a/tests/components/media_player/test_demo.py b/tests/components/media_player/test_demo.py index c9fb3ad6ff8..4da1fb6a725 100644 --- a/tests/components/media_player/test_demo.py +++ b/tests/components/media_player/test_demo.py @@ -34,7 +34,6 @@ class TestDemoMediaPlayer(unittest.TestCase): def test_source_select(self): """Test the input source service.""" - entity_id = 'media_player.lounge_room' assert setup_component( diff --git a/tests/components/media_player/test_sonos.py b/tests/components/media_player/test_sonos.py index b170f14c372..5c2911b2235 100644 --- a/tests/components/media_player/test_sonos.py +++ b/tests/components/media_player/test_sonos.py @@ -22,12 +22,17 @@ class socoDiscoverMock(): class AvTransportMock(): """Mock class for the avTransport property on soco.SoCo object.""" + def __init__(self): + """Initialize ethe Transport mock.""" pass def GetMediaInfo(self, _): - return {'CurrentURI': '', - 'CurrentURIMetaData': ''} + """Get the media details.""" + return { + 'CurrentURI': '', + 'CurrentURIMetaData': '' + } class SoCoMock(): @@ -102,18 +107,21 @@ def fake_add_device(devices, update_befor_add=False): class TestSonosMediaPlayer(unittest.TestCase): """Test the media_player module.""" - def setUp(self): # pylint: disable=invalid-name + # pylint: disable=invalid-name + def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() def monkey_available(self): + """Make a monkey available.""" return True # Monkey patches self.real_available = sonos.SonosDevice.available sonos.SonosDevice.available = monkey_available - def tearDown(self): # pylint: disable=invalid-name + # pylint: disable=invalid-name + def tearDown(self): """Stop everything that was started.""" # Monkey patches sonos.SonosDevice.available = self.real_available diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index 01eb81b261e..ff74c070d85 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -325,6 +325,7 @@ class TestMQTTCallbacks(unittest.TestCase): self.assertEqual({}, mqtt.MQTT_CLIENT.progress) def test_invalid_mqtt_topics(self): + """Test invalid topics.""" self.assertRaises(vol.Invalid, mqtt.valid_publish_topic, 'bad+topic') self.assertRaises(vol.Invalid, mqtt.valid_subscribe_topic, 'bad\0one') diff --git a/tests/components/switch/test_rfxtrx.py b/tests/components/switch/test_rfxtrx.py index f0d38ca20c3..ddee7cccaf7 100644 --- a/tests/components/switch/test_rfxtrx.py +++ b/tests/components/switch/test_rfxtrx.py @@ -49,6 +49,7 @@ class TestSwitchRfxtrx(unittest.TestCase): }}})) def test_invalid_config1(self): + """Test invalid configuration.""" self.assertFalse(setup_component(self.hass, 'switch', { 'switch': {'platform': 'rfxtrx', 'automatic_add': True, @@ -60,7 +61,7 @@ class TestSwitchRfxtrx(unittest.TestCase): }}})) def test_invalid_config2(self): - """Test configuration.""" + """Test invalid configuration.""" self.assertFalse(setup_component(self.hass, 'switch', { 'switch': {'platform': 'rfxtrx', 'automatic_add': True, @@ -73,6 +74,7 @@ class TestSwitchRfxtrx(unittest.TestCase): }}})) def test_invalid_config3(self): + """Test invalid configuration.""" self.assertFalse(setup_component(self.hass, 'switch', { 'switch': {'platform': 'rfxtrx', 'automatic_add': True, diff --git a/tests/components/test_conversation.py b/tests/components/test_conversation.py index 919c95be4c5..abe3a8f36f1 100644 --- a/tests/components/test_conversation.py +++ b/tests/components/test_conversation.py @@ -41,6 +41,7 @@ class TestConversation(unittest.TestCase): @callback def record_call(service): + """Recorder for a call.""" calls.append(service) self.hass.services.register('light', 'turn_on', record_call) @@ -60,6 +61,7 @@ class TestConversation(unittest.TestCase): @callback def record_call(service): + """Recorder for a call.""" calls.append(service) self.hass.services.register('light', 'turn_off', record_call) diff --git a/tests/components/test_sleepiq.py b/tests/components/test_sleepiq.py index 5bdfba4163d..965e0b6304a 100644 --- a/tests/components/test_sleepiq.py +++ b/tests/components/test_sleepiq.py @@ -9,6 +9,7 @@ from tests.common import load_fixture, get_test_home_assistant def mock_responses(mock): + """Mock responses for SleepIQ.""" base_url = 'https://api.sleepiq.sleepnumber.com/rest/' mock.put( base_url + 'login', diff --git a/tests/components/test_sun.py b/tests/components/test_sun.py index 15b79465b8f..9e5b15e6c2f 100644 --- a/tests/components/test_sun.py +++ b/tests/components/test_sun.py @@ -12,15 +12,14 @@ import homeassistant.components.sun as sun from tests.common import get_test_home_assistant +# pylint: disable=invalid-name class TestSun(unittest.TestCase): """Test the sun module.""" - # pylint: disable=invalid-name def setUp(self): """Setup things to be run when tests are started.""" self.hass = get_test_home_assistant() - # pylint: disable=invalid-name def tearDown(self): """Stop everything that was started.""" self.hass.stop()