mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Fix lint issues for 0.33 (#4451)
* Fix PEP257 issues * Fix ident * Fix lint issues * Update docstrings * Fix indent * Fix indent * Fix lint issues * Fix lint issue * Again lint
This commit is contained in:
parent
c86e1b31b3
commit
e6c4113c5b
@ -1,5 +1,5 @@
|
||||
"""
|
||||
Support for ZWave climate devices.
|
||||
Support for Z-Wave climate devices.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/climate.zwave/
|
||||
@ -17,7 +17,7 @@ from homeassistant.const import (
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_NAME = 'name'
|
||||
DEFAULT_NAME = 'ZWave Climate'
|
||||
DEFAULT_NAME = 'Z-Wave Climate'
|
||||
|
||||
REMOTEC = 0x5254
|
||||
REMOTEC_ZXT_120 = 0x8377
|
||||
@ -33,7 +33,7 @@ DEVICE_MAPPINGS = {
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
"""Setup the ZWave Climate devices."""
|
||||
"""Set up the Z-Wave Climate devices."""
|
||||
if discovery_info is None or zwave.NETWORK is None:
|
||||
_LOGGER.debug("No discovery_info=%s or no NETWORK=%s",
|
||||
discovery_info, zwave.NETWORK)
|
||||
@ -48,10 +48,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||
|
||||
|
||||
class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
|
||||
"""Represents a ZWave Climate device."""
|
||||
"""Representation of a Z-Wave Climate device."""
|
||||
|
||||
def __init__(self, value, temp_unit):
|
||||
"""Initialize the zwave climate device."""
|
||||
"""Initialize the Z-Wave climate device."""
|
||||
from openzwave.network import ZWaveNetwork
|
||||
from pydispatch import dispatcher
|
||||
ZWaveDeviceEntity.__init__(self, value, DOMAIN)
|
||||
@ -162,7 +162,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
"""No polling on ZWave."""
|
||||
"""No polling on Z-Wave."""
|
||||
return False
|
||||
|
||||
@property
|
||||
|
@ -86,14 +86,13 @@ class SwisscomDeviceScanner(object):
|
||||
|
||||
def get_swisscom_data(self):
|
||||
"""Retrieve data from Swisscom and return parsed result."""
|
||||
request = requests.post('http://' + self.host + '/ws', headers={
|
||||
'Content-Type': 'application/x-sah-ws-4-call+json'
|
||||
},
|
||||
data="""{"service":"Devices",
|
||||
"method":"get",
|
||||
"parameters":
|
||||
{"expression":"lan and not self"}}""",
|
||||
timeout=10)
|
||||
url = 'http://{}/ws'.format(self.host)
|
||||
headers = {'Content-Type': 'application/x-sah-ws-4-call+json'}
|
||||
data = """
|
||||
{"service":"Devices", "method":"get",
|
||||
"parameters":{"expression":"lan and not self"}}"""
|
||||
|
||||
request = requests.post(url, headers=headers, data=data, timeout=10)
|
||||
|
||||
devices = {}
|
||||
for device in request.json()['status']:
|
||||
|
@ -125,8 +125,8 @@ class WUndergroundSensor(Entity):
|
||||
"""Return the state of the sensor."""
|
||||
if self.rest.data:
|
||||
|
||||
if self._condition == 'elevation' and \
|
||||
self._condition in self.rest.data['observation_location']:
|
||||
if self._condition == 'elevation' and self._condition in \
|
||||
self.rest.data['observation_location']:
|
||||
return self.rest.data['observation_location'][self._condition]\
|
||||
.split()[0]
|
||||
|
||||
|
@ -29,11 +29,11 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def get_test_config_dir(*add_path):
|
||||
"""Return a path to a test config dir."""
|
||||
return os.path.join(os.path.dirname(__file__), "testing_config", *add_path)
|
||||
return os.path.join(os.path.dirname(__file__), 'testing_config', *add_path)
|
||||
|
||||
|
||||
def get_test_home_assistant():
|
||||
"""Return a Home Assistant object pointing at test config dir."""
|
||||
"""Return a Home Assistant object pointing at test config directory."""
|
||||
if sys.platform == "win32":
|
||||
loop = asyncio.ProactorEventLoop()
|
||||
else:
|
||||
@ -75,6 +75,7 @@ def get_test_home_assistant():
|
||||
return hass
|
||||
|
||||
|
||||
# pylint: disable=protected-access
|
||||
@asyncio.coroutine
|
||||
def async_test_home_assistant(loop):
|
||||
"""Return a Home Assistant object pointing at test config dir."""
|
||||
@ -101,9 +102,10 @@ def async_test_home_assistant(loop):
|
||||
|
||||
@asyncio.coroutine
|
||||
def mock_async_start():
|
||||
with patch.object(loop, 'add_signal_handler'), \
|
||||
patch('homeassistant.core._async_create_timer'), \
|
||||
patch.object(hass, '_async_tasks_cleanup', return_value=None):
|
||||
"""Start the mocking."""
|
||||
with patch.object(loop, 'add_signal_handler'),\
|
||||
patch('homeassistant.core._async_create_timer'),\
|
||||
patch.object(hass, '_async_tasks_cleanup', return_value=None):
|
||||
yield from orig_start()
|
||||
|
||||
hass.async_start = mock_async_start
|
||||
@ -130,8 +132,10 @@ def mock_service(hass, domain, service):
|
||||
"""
|
||||
calls = []
|
||||
|
||||
# pylint: disable=redefined-outer-name
|
||||
@ha.callback
|
||||
def mock_service(call):
|
||||
""""Mocked service call."""
|
||||
calls.append(call)
|
||||
|
||||
# pylint: disable=unnecessary-lambda
|
||||
|
@ -8,8 +8,8 @@ import rxv
|
||||
def sample_content(name):
|
||||
"""Read content into a string from a file."""
|
||||
with open('tests/components/media_player/yamaha_samples/%s' % name,
|
||||
encoding='utf-8') as f:
|
||||
return f.read()
|
||||
encoding='utf-8') as content:
|
||||
return content.read()
|
||||
|
||||
|
||||
class FakeYamaha(rxv.rxv.RXV):
|
||||
@ -20,21 +20,25 @@ class FakeYamaha(rxv.rxv.RXV):
|
||||
ensure that usage of the rxv library by HomeAssistant is as we'd
|
||||
expect.
|
||||
"""
|
||||
_fake_input = "HDMI1"
|
||||
_fake_input = 'HDMI1'
|
||||
|
||||
def _discover_features(self):
|
||||
self._desc_xml = ET.fromstring(sample_content("desc.xml"))
|
||||
"""Fake the discovery feature."""
|
||||
self._desc_xml = ET.fromstring(sample_content('desc.xml'))
|
||||
|
||||
@property
|
||||
def input(self):
|
||||
"""A fake input for the reciever."""
|
||||
return self._fake_input
|
||||
|
||||
@input.setter
|
||||
def input(self, input_name):
|
||||
"""Set the input for the fake receiver."""
|
||||
assert input_name in self.inputs()
|
||||
self._fake_input = input_name
|
||||
|
||||
def inputs(self):
|
||||
"""All inputs of the the fake receiver."""
|
||||
return {'AUDIO1': None,
|
||||
'AUDIO2': None,
|
||||
'AV1': None,
|
||||
@ -61,15 +65,17 @@ class FakeYamaha(rxv.rxv.RXV):
|
||||
'iPod (USB)': 'iPod_USB'}
|
||||
|
||||
|
||||
# pylint: disable=no-member, invalid-name
|
||||
class TestYamaha(unittest.TestCase):
|
||||
"""Test the media_player yamaha module."""
|
||||
|
||||
def setUp(self): # pylint: disable=invalid-name
|
||||
def setUp(self):
|
||||
"""Setup things to be run when tests are started."""
|
||||
super(TestYamaha, self).setUp()
|
||||
self.rec = FakeYamaha('10.0.0.0')
|
||||
|
||||
def test_get_playback_support(self):
|
||||
"""Test the playback"""
|
||||
rec = self.rec
|
||||
support = rec.get_playback_support()
|
||||
self.assertFalse(support.play)
|
||||
@ -78,7 +84,7 @@ class TestYamaha(unittest.TestCase):
|
||||
self.assertFalse(support.skip_f)
|
||||
self.assertFalse(support.skip_r)
|
||||
|
||||
rec.input = "NET RADIO"
|
||||
rec.input = 'NET RADIO'
|
||||
support = rec.get_playback_support()
|
||||
self.assertTrue(support.play)
|
||||
self.assertFalse(support.pause)
|
||||
|
@ -1,4 +1,4 @@
|
||||
"""the tests for the Command line switch platform."""
|
||||
"""The tests for the Command line switch platform."""
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
@ -12,14 +12,15 @@ import homeassistant.components.switch.command_line as command_line
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
class TestCommandSwitch(unittest.TestCase):
|
||||
"""Test the command switch."""
|
||||
|
||||
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()
|
||||
|
||||
def tearDown(self): # pylint: disable=invalid-name
|
||||
def tearDown(self):
|
||||
"""Stop everything that was started."""
|
||||
self.hass.stop()
|
||||
|
||||
@ -165,13 +166,13 @@ class TestCommandSwitch(unittest.TestCase):
|
||||
# args: hass, device_name, friendly_name, command_on, command_off,
|
||||
# command_state, value_template
|
||||
init_args = [
|
||||
self.hass,
|
||||
"test_device_name",
|
||||
"Test friendly name!",
|
||||
"echo 'on command'",
|
||||
"echo 'off command'",
|
||||
False,
|
||||
None
|
||||
self.hass,
|
||||
"test_device_name",
|
||||
"Test friendly name!",
|
||||
"echo 'on command'",
|
||||
"echo 'off command'",
|
||||
False,
|
||||
None,
|
||||
]
|
||||
|
||||
no_state_device = command_line.CommandSwitch(*init_args)
|
||||
@ -188,13 +189,13 @@ class TestCommandSwitch(unittest.TestCase):
|
||||
self.hass = get_test_home_assistant()
|
||||
|
||||
init_args = [
|
||||
self.hass,
|
||||
"test_device_name",
|
||||
"Test friendly name!",
|
||||
"echo 'on command'",
|
||||
"echo 'off command'",
|
||||
False,
|
||||
None
|
||||
self.hass,
|
||||
"test_device_name",
|
||||
"Test friendly name!",
|
||||
"echo 'on command'",
|
||||
"echo 'off command'",
|
||||
False,
|
||||
None,
|
||||
]
|
||||
|
||||
test_switch = command_line.CommandSwitch(*init_args)
|
||||
|
@ -17,12 +17,12 @@ from tests.common import get_test_instance_port, get_test_home_assistant
|
||||
HTTP_SERVER_PORT = get_test_instance_port()
|
||||
BRIDGE_SERVER_PORT = get_test_instance_port()
|
||||
|
||||
BRIDGE_URL_BASE = "http://127.0.0.1:{}".format(BRIDGE_SERVER_PORT) + "{}"
|
||||
BRIDGE_URL_BASE = 'http://127.0.0.1:{}'.format(BRIDGE_SERVER_PORT) + '{}'
|
||||
JSON_HEADERS = {const.HTTP_HEADER_CONTENT_TYPE: const.CONTENT_TYPE_JSON}
|
||||
|
||||
|
||||
def setup_hass_instance(emulated_hue_config):
|
||||
"""Setup the Home Assistant instance to test."""
|
||||
"""Set up the Home Assistant instance to test."""
|
||||
hass = get_test_home_assistant()
|
||||
|
||||
# We need to do this to get access to homeassistant/turn_(on,off)
|
||||
@ -75,6 +75,7 @@ class TestEmulatedHue(unittest.TestCase):
|
||||
self.assertTrue('text/xml' in result.headers['content-type'])
|
||||
|
||||
# Make sure the XML is parsable
|
||||
# pylint: disable=bare-except
|
||||
try:
|
||||
ET.fromstring(result.text)
|
||||
except:
|
||||
@ -130,19 +131,20 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
|
||||
})
|
||||
|
||||
bootstrap.setup_component(cls.hass, script.DOMAIN, {
|
||||
'script': {
|
||||
'set_kitchen_light': {
|
||||
'sequence': [
|
||||
{
|
||||
'service_template': "light.turn_{{ requested_state }}",
|
||||
'data_template': {
|
||||
'entity_id': 'light.kitchen_lights',
|
||||
'brightness': "{{ requested_level }}"
|
||||
}
|
||||
'script': {
|
||||
'set_kitchen_light': {
|
||||
'sequence': [
|
||||
{
|
||||
'service_template':
|
||||
"light.turn_{{ requested_state }}",
|
||||
'data_template': {
|
||||
'entity_id': 'light.kitchen_lights',
|
||||
'brightness': "{{ requested_level }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
start_hass_instance(cls.hass)
|
||||
@ -285,6 +287,7 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
|
||||
kitchen_light.attributes[light.ATTR_BRIGHTNESS],
|
||||
level)
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def test_put_with_form_urlencoded_content_type(self):
|
||||
"""Test the form with urlencoded content."""
|
||||
# Needed for Alexa
|
||||
@ -296,7 +299,7 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
|
||||
result = requests.put(
|
||||
BRIDGE_URL_BASE.format(
|
||||
'/api/username/lights/{}/state'.format(
|
||||
"light.ceiling_lights")), data=data)
|
||||
'light.ceiling_lights')), data=data)
|
||||
|
||||
self.assertEqual(result.status_code, 400)
|
||||
|
||||
@ -344,8 +347,8 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
|
||||
result = requests.put(
|
||||
BRIDGE_URL_BASE.format(
|
||||
'/api/username/lights/{}/state'.format(
|
||||
"light.ceiling_lights")),
|
||||
data=json.dumps({HUE_API_STATE_ON: 1234}))
|
||||
'light.ceiling_lights')),
|
||||
data=json.dumps({HUE_API_STATE_ON: 1234}))
|
||||
|
||||
self.assertEqual(result.status_code, 400)
|
||||
|
||||
@ -353,13 +356,14 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
|
||||
result = requests.put(
|
||||
BRIDGE_URL_BASE.format(
|
||||
'/api/username/lights/{}/state'.format(
|
||||
"light.ceiling_lights")), data=json.dumps({
|
||||
'light.ceiling_lights')), data=json.dumps({
|
||||
HUE_API_STATE_ON: True,
|
||||
HUE_API_STATE_BRI: 'Hello world!'
|
||||
}))
|
||||
|
||||
self.assertEqual(result.status_code, 400)
|
||||
|
||||
# pylint: disable=invalid-name
|
||||
def perform_put_test_on_ceiling_lights(self,
|
||||
content_type='application/json'):
|
||||
"""Test the setting of a light."""
|
||||
@ -405,6 +409,7 @@ class TestEmulatedHueExposedByDefault(unittest.TestCase):
|
||||
|
||||
return None
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def perform_put_light_state(self, entity_id, is_on, brightness=None,
|
||||
content_type='application/json'):
|
||||
"""Test the setting of a light state."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user