Disable too-many-* (#4107)

* Disable too-many-* and too-few-public-methods

* Remove globally disabled pylint warnings
This commit is contained in:
Fabian Affolter authored and GitHub committed 2016-10-30 22:18:53 +01:00
1 parent b910a9917d
commit be272ac64a
298 files changed
+271 -570

No files matched your search

+2 -2
View File
@@ -223,7 +223,7 @@ def mock_mqtt_component(hass):
class MockModule(object):
"""Representation of a fake module."""
# pylint: disable=invalid-name,too-few-public-methods,too-many-arguments
# pylint: disable=invalid-name
def __init__(self, domain=None, dependencies=None, setup=None,
requirements=None, config_schema=None, platform_schema=None):
"""Initialize the mock module."""
@@ -248,7 +248,7 @@ class MockModule(object):
class MockPlatform(object):
"""Provide a fake platform."""
# pylint: disable=invalid-name,too-few-public-methods
# pylint: disable=invalid-name
def __init__(self, setup_platform=None, dependencies=None,
platform_schema=None):
"""Initialize the platform."""
+15 -11
View File
@@ -1,5 +1,5 @@
"""The tests for the device tracker component."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import logging
import unittest
from unittest.mock import call, patch
@@ -30,12 +30,14 @@ class TestComponentsDeviceTracker(unittest.TestCase):
hass = None # HomeAssistant
yaml_devices = None # type: str
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()
self.yaml_devices = self.hass.config.path(device_tracker.YAML_DEVICES)
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
try:
os.remove(self.yaml_devices)
@@ -56,7 +58,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
self.assertFalse(device_tracker.is_on(self.hass, entity_id))
def test_reading_broken_yaml_config(self): # pylint: disable=no-self-use
# pylint: disable=no-self-use
def test_reading_broken_yaml_config(self):
"""Test when known devices contains invalid data."""
files = {'empty.yaml': '',
'nodict.yaml': '100',
@@ -101,9 +104,9 @@ class TestComponentsDeviceTracker(unittest.TestCase):
self.assertEqual(device.away_hide, config.away_hide)
self.assertEqual(device.consider_home, config.consider_home)
# pylint: disable=invalid-name
@patch('homeassistant.components.device_tracker._LOGGER.warning')
def test_track_with_duplicate_mac_dev_id(self, mock_warning): \
# pylint: disable=invalid-name
def test_track_with_duplicate_mac_dev_id(self, mock_warning):
"""Test adding duplicate MACs or device IDs to DeviceTracker."""
devices = [
device_tracker.Device(self.hass, True, True, 'my_device', 'AB:01',
@@ -138,8 +141,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
def test_adding_unknown_device_to_config(self): \
# pylint: disable=invalid-name
# pylint: disable=invalid-name
def test_adding_unknown_device_to_config(self):
"""Test the adding of unknown devices to configuration file."""
scanner = get_component('device_tracker.test').SCANNER
scanner.reset()
@@ -303,8 +306,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
self.assertEqual(mock_see.call_count, 1)
self.assertEqual(mock_see.call_args, call(**params))
def test_not_write_duplicate_yaml_keys(self): \
# pylint: disable=invalid-name
# pylint: disable=invalid-name
def test_not_write_duplicate_yaml_keys(self):
"""Test that the device tracker will not generate invalid YAML."""
self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
@@ -318,7 +321,8 @@ class TestComponentsDeviceTracker(unittest.TestCase):
timedelta(seconds=0))
assert len(config) == 2
def test_not_allow_invalid_dev_id(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def test_not_allow_invalid_dev_id(self):
"""Test that the device tracker will not allow invalid dev ids."""
self.assertTrue(setup_component(self.hass, device_tracker.DOMAIN,
TEST_PLATFORM))
@@ -26,9 +26,10 @@ def _url(data=None):
return "{}{}locative?{}".format(HTTP_BASE_URL, const.URL_API, data)
def setUpModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUpModule():
"""Initalize a Home Assistant server."""
global hass # pylint: disable=invalid-name
global hass
hass = get_test_home_assistant()
bootstrap.setup_component(hass, http.DOMAIN, {
@@ -242,12 +242,10 @@ class BaseMQTT(unittest.TestCase):
self.assertEqual(state.attributes.get('gps_accuracy'), accuracy)
# pylint: disable=too-many-public-methods
class TestDeviceTrackerOwnTracks(BaseMQTT):
"""Test the OwnTrack sensor."""
# pylint: disable=invalid-name
def setup_method(self, _):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the demo light component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from homeassistant.bootstrap import setup_component
@@ -13,14 +13,16 @@ ENTITY_LIGHT = 'light.bed_light'
class TestDemoClimate(unittest.TestCase):
"""Test the demo climate hvac."""
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()
self.assertTrue(setup_component(self.hass, light.DOMAIN, {'light': {
'platform': 'demo',
}}))
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Light component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
import os
@@ -16,11 +16,13 @@ from tests.common import mock_service, get_test_home_assistant
class TestLight(unittest.TestCase):
"""Test the light 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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+1 -1
View File
@@ -1,5 +1,5 @@
"""The tests for the Cast Media player platform."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from unittest.mock import patch
+4 -2
View File
@@ -17,7 +17,8 @@ def fire_pilight_message(protocol, data):
HASS.bus.fire(pilight.EVENT, message)
def setup_function(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setup_function():
"""Initialize a Home Assistant server."""
global HASS
@@ -25,7 +26,8 @@ def setup_function(): # pylint: disable=invalid-name
HASS.config.components = ['pilight']
def teardown_function(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def teardown_function():
"""Stop the Home Assistant server."""
HASS.stop()
@@ -31,7 +31,6 @@ ALERT_MESSAGE = 'This is a test alert message'
def mocked_requests_get(*args, **kwargs):
"""Mock requests.get invocations."""
# pylint: disable=too-few-public-methods
class MockResponse:
"""Class to represent a mocked response."""
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Switch component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from homeassistant.bootstrap import setup_component
@@ -13,7 +13,8 @@ from tests.common import get_test_home_assistant
class TestSwitch(unittest.TestCase):
"""Test the switch 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()
platform = loader.get_component('switch.test')
@@ -22,7 +23,8 @@ class TestSwitch(unittest.TestCase):
self.switch_1, self.switch_2, self.switch_3 = \
platform.DEVICES
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Alexa component."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import json
import time
import datetime
@@ -36,7 +36,8 @@ NPR_NEWS_MP3_URL = "https://pd.npr.org/anon.npr-mp3/npr/news/newscast.mp3"
STATIC_TIME = datetime.datetime.utcfromtimestamp(1476129102)
def setUpModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUpModule():
"""Initialize a Home Assistant server for testing this module."""
global hass
@@ -117,7 +118,8 @@ def setUpModule(): # pylint: disable=invalid-name
time.sleep(0.05)
def tearDownModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDownModule():
"""Stop the Home Assistant server."""
hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Home Assistant API component."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import asyncio
from contextlib import closing
import json
@@ -32,7 +32,8 @@ def _url(path=""):
return HTTP_BASE_URL + path
def setUpModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUpModule():
"""Initialize a Home Assistant server."""
global hass
@@ -52,7 +53,8 @@ def setUpModule(): # pylint: disable=invalid-name
time.sleep(0.05)
def tearDownModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDownModule():
"""Stop the Home Assistant server."""
hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Configurator component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
import homeassistant.components.configurator as configurator
@@ -11,11 +11,13 @@ from tests.common import get_test_home_assistant
class TestConfigurator(unittest.TestCase):
"""Test the Configurator component."""
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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Conversation component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from unittest.mock import patch
@@ -15,7 +15,8 @@ from tests.common import get_test_home_assistant, assert_setup_component
class TestConversation(unittest.TestCase):
"""Test the conversation component."""
def setUp(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUp(self):
"""Setup things to be run when tests are started."""
self.ent_id = 'light.kitchen_lights'
self.hass = get_test_home_assistant(3)
@@ -28,7 +29,8 @@ class TestConversation(unittest.TestCase):
conversation.DOMAIN: {}
}))
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
@@ -1,5 +1,5 @@
"""The tests device sun light trigger component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import os
import unittest
@@ -19,7 +19,8 @@ KNOWN_DEV_YAML_PATH = os.path.join(get_test_config_dir(),
device_tracker.YAML_DEVICES)
def setUpModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUpModule():
"""Write a device tracker known devices file to be used."""
device_tracker.update_config(
KNOWN_DEV_YAML_PATH, 'device_1', device_tracker.Device(
@@ -32,7 +33,8 @@ def setUpModule(): # pylint: disable=invalid-name
picture='http://example.com/dev2.jpg'))
def tearDownModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDownModule():
"""Remove device tracker known devices file."""
os.remove(KNOWN_DEV_YAML_PATH)
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for Home Assistant frontend."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import re
import time
import unittest
@@ -25,7 +25,8 @@ def _url(path=""):
return HTTP_BASE_URL + path
def setUpModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUpModule():
"""Initialize a Home Assistant server."""
global hass
@@ -45,7 +46,8 @@ def setUpModule(): # pylint: disable=invalid-name
time.sleep(0.05)
def tearDownModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDownModule():
"""Stop everything that was started."""
hass.stop()
frontend.PANELS = {}
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Group components."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
from collections import OrderedDict
import unittest
from unittest.mock import patch
@@ -16,11 +16,13 @@ from tests.common import get_test_home_assistant
class TestComponentsGroup(unittest.TestCase):
"""Test Group component."""
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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests the History component."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
from datetime import timedelta
import unittest
from unittest.mock import patch, sentinel
@@ -16,11 +16,13 @@ from tests.common import (
class TestComponentHistory(unittest.TestCase):
"""Test History component."""
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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+3 -2
View File
@@ -1,5 +1,5 @@
"""The tests for the Home Assistant HTTP component."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import logging
import time
from ipaddress import ip_network
@@ -64,7 +64,8 @@ def setUpModule():
time.sleep(0.05)
def tearDownModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDownModule():
"""Stop the Home Assistant server."""
hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The testd for Core components."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import asyncio
import unittest
from unittest.mock import patch, Mock
@@ -21,7 +21,8 @@ from tests.common import (
class TestComponentsCore(unittest.TestCase):
"""Test homeassistant.components 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()
self.assertTrue(run_coroutine_threadsafe(
@@ -31,7 +32,8 @@ class TestComponentsCore(unittest.TestCase):
self.hass.states.set('light.Bowl', STATE_ON)
self.hass.states.set('light.Ceiling', STATE_OFF)
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the input_boolean component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
import logging
@@ -17,11 +17,13 @@ _LOGGER = logging.getLogger(__name__)
class TestInputBoolean(unittest.TestCase):
"""Test the input boolean 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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Input select component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from tests.common import get_test_home_assistant
@@ -14,11 +14,13 @@ from homeassistant.const import (
class TestInputSelect(unittest.TestCase):
"""Test the input select component."""
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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Input slider component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from tests.common import get_test_home_assistant
@@ -11,11 +11,13 @@ from homeassistant.components.input_slider import (DOMAIN, select_value)
class TestInputSlider(unittest.TestCase):
"""Test the input slider component."""
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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+1 -1
View File
@@ -1,5 +1,5 @@
"""The tests for the logbook component."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
from datetime import timedelta
import unittest
from unittest.mock import patch
+1 -1
View File
@@ -1,5 +1,5 @@
"""The tests for the Rfxtrx component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
import pytest
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Script component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from homeassistant.bootstrap import setup_component
@@ -14,12 +14,14 @@ ENTITY_ID = 'script.test'
class TestScriptComponent(unittest.TestCase):
"""Test the Script component."""
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()
self.hass.config.components.append('group')
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down everything that was started."""
self.hass.stop()
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Sun component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
from unittest.mock import patch
from datetime import timedelta, datetime
@@ -15,11 +15,13 @@ from tests.common import get_test_home_assistant
class TestSun(unittest.TestCase):
"""Test the sun 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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+1 -1
View File
@@ -1,5 +1,5 @@
"""Test the entity helper."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import asyncio
from unittest.mock import MagicMock
+1 -1
View File
@@ -1,5 +1,5 @@
"""The tests for the Entity component helper."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
from collections import OrderedDict
import logging
import unittest
+5 -4
View File
@@ -1,6 +1,5 @@
"""Test event helpers."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=too-few-public-methods
# pylint: disable=protected-access
import asyncio
import unittest
from datetime import datetime, timedelta
@@ -28,11 +27,13 @@ from tests.common import get_test_home_assistant
class TestEventHelpers(unittest.TestCase):
"""Test the Home Assistant event helpers."""
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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+5 -4
View File
@@ -1,6 +1,5 @@
"""Test event decorator helpers."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=too-few-public-methods
# pylint: disable=protected-access
import unittest
from datetime import datetime, timedelta
@@ -20,7 +19,8 @@ from tests.common import get_test_home_assistant
class TestEventDecoratorHelpers(unittest.TestCase):
"""Test the Home Assistant event helpers."""
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()
self.hass.states.set("light.Bowl", "on")
@@ -28,7 +28,8 @@ class TestEventDecoratorHelpers(unittest.TestCase):
event_decorators.HASS = self.hass
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
event_decorators.HASS = None
+5 -3
View File
@@ -1,5 +1,5 @@
"""Test component helpers."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
from collections import OrderedDict
import unittest
@@ -11,11 +11,13 @@ from tests.common import get_test_home_assistant
class TestHelpers(unittest.TestCase):
"""Tests homeassistant.helpers module."""
def setUp(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUp(self):
"""Init needed objects."""
self.hass = get_test_home_assistant()
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
-1
View File
@@ -1,5 +1,4 @@
"""Tests Home Assistant location helpers."""
# pylint: disable=too-many-public-methods
import unittest
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE
+5 -3
View File
@@ -1,5 +1,5 @@
"""The tests for the Script component."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
from datetime import timedelta
from unittest import mock
import unittest
@@ -18,11 +18,13 @@ ENTITY_ID = 'script.test'
class TestScriptHelper(unittest.TestCase):
"""Test the Script component."""
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 tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down everything that was started."""
self.hass.stop()
+4 -3
View File
@@ -1,5 +1,4 @@
"""Test Home Assistant template helper methods."""
# pylint: disable=too-many-public-methods
import unittest
from unittest.mock import patch
@@ -22,14 +21,16 @@ from tests.common import get_test_home_assistant
class TestHelpersTemplate(unittest.TestCase):
"""Test the Template."""
def setUp(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUp(self):
"""Setup the tests."""
self.hass = get_test_home_assistant()
self.hass.config.units = UnitSystem('custom', TEMP_CELSIUS,
LENGTH_METERS, VOLUME_LITERS,
MASS_GRAMS)
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down stuff we started."""
self.hass.stop()
+1 -2
View File
@@ -1,5 +1,5 @@
"""Test the bootstrapping."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
from unittest import mock
import threading
import logging
@@ -26,7 +26,6 @@ class TestBootstrap:
backup_cache = None
# pylint: disable=invalid-name, no-self-use
def setup_method(self, method):
"""Setup the test."""
self.backup_cache = loader._COMPONENT_CACHE
+5 -3
View File
@@ -1,5 +1,5 @@
"""Test config utils."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import os
import unittest
import unittest.mock as mock
@@ -35,11 +35,13 @@ def create_file(path):
class TestConfig(unittest.TestCase):
"""Test the configutils."""
def setUp(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUp(self):
"""Initialize a test Home Assistant instance."""
self.hass = get_test_home_assistant()
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Clean up."""
dt_util.DEFAULT_TIME_ZONE = ORIG_TIMEZONE
+19 -11
View File
@@ -1,6 +1,5 @@
"""Test to verify that Home Assistant core works."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=too-few-public-methods
# pylint: disable=protected-access
import asyncio
import unittest
from unittest.mock import patch, MagicMock
@@ -89,11 +88,13 @@ def test_async_run_job_delegates_non_async():
class TestHomeAssistant(unittest.TestCase):
"""Test the Home Assistant core classes."""
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(0)
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
@@ -163,13 +164,15 @@ class TestEvent(unittest.TestCase):
class TestEventBus(unittest.TestCase):
"""Test EventBus methods."""
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()
self.bus = self.hass.bus
self.bus.listen('test_event', lambda x: len)
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down stuff we started."""
self.hass.stop()
@@ -360,14 +363,16 @@ class TestState(unittest.TestCase):
class TestStateMachine(unittest.TestCase):
"""Test State machine methods."""
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(0)
self.states = self.hass.states
self.states.set("light.Bowl", "on")
self.states.set("switch.AC", "off")
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down stuff we started."""
self.hass.stop()
@@ -485,13 +490,15 @@ class TestServiceCall(unittest.TestCase):
class TestServiceRegistry(unittest.TestCase):
"""Test ServicerRegistry methods."""
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()
self.services = self.hass.services
self.services.register("Test_Domain", "TEST_SERVICE", lambda x: None)
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop down stuff we started."""
self.hass.stop()
@@ -572,7 +579,8 @@ class TestServiceRegistry(unittest.TestCase):
class TestConfig(unittest.TestCase):
"""Test configuration methods."""
def setUp(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUp(self):
"""Setup things to be run when tests are started."""
self.config = ha.Config()
self.assertIsNone(self.config.config_dir)
+5 -3
View File
@@ -1,5 +1,5 @@
"""Test to verify that we can load components."""
# pylint: disable=too-many-public-methods,protected-access
# pylint: disable=protected-access
import unittest
import homeassistant.loader as loader
@@ -11,11 +11,13 @@ from tests.common import get_test_home_assistant, MockModule
class TestLoader(unittest.TestCase):
"""Test the loader module."""
def setUp(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUp(self):
"""Setup tests."""
self.hass = get_test_home_assistant()
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Stop everything that was started."""
self.hass.stop()
+11 -9
View File
@@ -1,5 +1,5 @@
"""Test Home Assistant remote methods and classes."""
# pylint: disable=protected-access,too-many-public-methods
# pylint: disable=protected-access
import asyncio
import threading
import time
@@ -16,11 +16,11 @@ import homeassistant.util.dt as dt_util
from tests.common import (
get_test_instance_port, get_test_home_assistant, get_test_config_dir)
API_PASSWORD = "test1234"
API_PASSWORD = 'test1234'
MASTER_PORT = get_test_instance_port()
SLAVE_PORT = get_test_instance_port()
BROKEN_PORT = get_test_instance_port()
HTTP_BASE_URL = "http://127.0.0.1:{}".format(MASTER_PORT)
HTTP_BASE_URL = 'http://127.0.0.1:{}'.format(MASTER_PORT)
HA_HEADERS = {HTTP_HEADER_HA_AUTH: API_PASSWORD}
@@ -28,12 +28,13 @@ broken_api = remote.API('127.0.0.1', "bladiebla")
hass, slave, master_api = None, None, None
def _url(path=""):
def _url(path=''):
"""Helper method to generate URLs."""
return HTTP_BASE_URL + path
def setUpModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def setUpModule():
"""Initalization of a Home Assistant server and Slave instance."""
global hass, slave, master_api
@@ -52,13 +53,13 @@ def setUpModule(): # pylint: disable=invalid-name
hass.start()
time.sleep(0.05)
master_api = remote.API("127.0.0.1", API_PASSWORD, MASTER_PORT)
master_api = remote.API('127.0.0.1', API_PASSWORD, MASTER_PORT)
# Start slave
loop = asyncio.new_event_loop()
# FIXME: should not be a daemon
threading.Thread(name="SlaveThread", daemon=True,
threading.Thread(name='SlaveThread', daemon=True,
target=loop.run_forever).start()
slave = remote.HomeAssistant(master_api, loop=loop)
@@ -73,7 +74,8 @@ def setUpModule(): # pylint: disable=invalid-name
slave.start()
def tearDownModule(): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDownModule():
"""Stop the Home Assistant server and slave."""
slave.stop()
hass.stop()
@@ -94,7 +96,7 @@ class TestRemoteMethods(unittest.TestCase):
self.assertEqual(
remote.APIStatus.INVALID_PASSWORD,
remote.validate_api(
remote.API("127.0.0.1", API_PASSWORD + "A", MASTER_PORT)))
remote.API('127.0.0.1', API_PASSWORD + 'A', MASTER_PORT)))
self.assertEqual(
remote.APIStatus.CANNOT_CONNECT, remote.validate_api(broken_api))
-1
View File
@@ -1,5 +1,4 @@
"""Test Home Assistant date util methods."""
# pylint: disable=too-many-public-methods
import unittest
from datetime import datetime, timedelta
-1
View File
@@ -1,5 +1,4 @@
"""Test Home Assistant util methods."""
# pylint: disable=too-many-public-methods
import unittest
from unittest.mock import patch
from datetime import datetime, timedelta
-1
View File
@@ -1,5 +1,4 @@
"""Test Home Assistant location util methods."""
# pylint: disable=too-many-public-methods
from unittest import TestCase
from unittest.mock import patch
+5 -4
View File
@@ -12,7 +12,7 @@ from tests.common import get_test_config_dir, patch_yaml_files
class TestYaml(unittest.TestCase):
"""Test util.yaml loader."""
# pylint: disable=no-self-use,invalid-name
# pylint: disable=no-self-use, invalid-name
def test_simple_list(self):
"""Test simple list."""
@@ -254,7 +254,7 @@ def load_yaml(fname, string):
return load_yaml_config_file(fname)
class FakeKeyring(): # pylint: disable=too-few-public-methods
class FakeKeyring():
"""Fake a keyring class."""
def __init__(self, secrets_dict):
@@ -270,7 +270,7 @@ class FakeKeyring(): # pylint: disable=too-few-public-methods
class TestSecrets(unittest.TestCase):
"""Test the secrets parameter in the yaml utility."""
# pylint: disable=protected-access,invalid-name
# pylint: disable=protected-access, invalid-name
def setUp(self): # pylint: disable=invalid-name
"""Create & load secrets file."""
@@ -295,7 +295,8 @@ class TestSecrets(unittest.TestCase):
' password: !secret comp1_pw\n'
'')
def tearDown(self): # pylint: disable=invalid-name
# pylint: disable=invalid-name
def tearDown(self):
"""Clean up secrets."""
yaml.clear_secret_cache()
FILES.clear()