Fix PEP257 issues

This commit is contained in:
Fabian Affolter committed 2016-03-09 10:25:50 +01:00
1 parent d6eab03a61
commit 9838697d2b
120 files changed
+1447 -1297

No files matched your search

+1
View File
@@ -0,0 +1 @@
"""The tests for Sensor platforms."""
+10 -14
View File
@@ -1,9 +1,4 @@
"""
tests.components.sensor.test_command_line
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests command sensor.
"""
"""The tests for the Command line sensor platform."""
import unittest
from homeassistant.components.sensor import command_line
@@ -12,24 +7,25 @@ from tests.common import get_test_home_assistant
class TestCommandSensorSensor(unittest.TestCase):
""" Test the Command line sensor. """
"""Test the Command line sensor."""
def setUp(self):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
def tearDown(self):
""" Stop down stuff we started. """
"""Stop everything that was started."""
self.hass.stop()
def test_setup(self):
""" Test sensor setup. """
"""Test sensor setup."""
config = {'name': 'Test',
'unit_of_measurement': 'in',
'command': 'echo 5'}
devices = []
def add_dev_callback(devs):
""" callback to add device """
"""Add callback to add devices."""
for dev in devs:
devices.append(dev)
@@ -43,13 +39,13 @@ class TestCommandSensorSensor(unittest.TestCase):
self.assertEqual('5', entity.state)
def test_setup_bad_config(self):
""" Test setup with a bad configuration. """
"""Test setup with a bad configuration."""
config = {}
devices = []
def add_dev_callback(devs):
""" callback to add device """
"""Add a callback to add devices."""
for dev in devs:
devices.append(dev)
@@ -59,7 +55,7 @@ class TestCommandSensorSensor(unittest.TestCase):
self.assertEqual(0, len(devices))
def test_template(self):
""" Test command sensor with template. """
"""Test command sensor with template."""
data = command_line.CommandSensorData('echo 50')
entity = command_line.CommandSensor(
@@ -68,7 +64,7 @@ class TestCommandSensorSensor(unittest.TestCase):
self.assertEqual(5, float(entity.state))
def test_bad_command(self):
""" Test bad command. """
"""Test bad command."""
data = command_line.CommandSensorData('asdfasdf')
data.update()
+24 -8
View File
@@ -1,9 +1,4 @@
"""
tests.components.sensor.test_mfi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests mFi sensor.
"""
"""The tests for the mFi sensor platform."""
import unittest
import unittest.mock as mock
@@ -17,6 +12,8 @@ from tests.common import get_test_home_assistant
class TestMfiSensorSetup(unittest.TestCase):
"""Test the mFi sensor platform."""
PLATFORM = mfi
COMPONENT = sensor
THING = 'sensor'
@@ -33,15 +30,17 @@ class TestMfiSensorSetup(unittest.TestCase):
}
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.config.latitude = 32.87336
self.hass.config.longitude = 117.22743
def teardown_method(self, method):
""" Stop down stuff we started. """
"""Stop everything that was started."""
self.hass.stop()
def test_setup_missing_config(self):
"""Test setup with missing configuration."""
config = {
'sensor': {
'platform': 'mfi',
@@ -51,6 +50,7 @@ class TestMfiSensorSetup(unittest.TestCase):
@mock.patch('mficlient.client')
def test_setup_failed_login(self, mock_client):
"""Test setup with login failure."""
mock_client.FailedToLogin = Exception()
mock_client.MFiClient.side_effect = mock_client.FailedToLogin
self.assertFalse(
@@ -60,6 +60,7 @@ class TestMfiSensorSetup(unittest.TestCase):
@mock.patch('mficlient.client')
def test_setup_failed_connect(self, mock_client):
"""Test setup with conection failure."""
mock_client.FailedToLogin = Exception()
mock_client.MFiClient.side_effect = requests.exceptions.ConnectionError
self.assertFalse(
@@ -69,6 +70,7 @@ class TestMfiSensorSetup(unittest.TestCase):
@mock.patch('mficlient.client.MFiClient')
def test_setup_minimum(self, mock_client):
"""Test setup with minimum configuration."""
config = dict(self.GOOD_CONFIG)
del config[self.THING]['port']
assert self.COMPONENT.setup(self.hass, config)
@@ -78,6 +80,7 @@ class TestMfiSensorSetup(unittest.TestCase):
@mock.patch('mficlient.client.MFiClient')
def test_setup_with_port(self, mock_client):
"""Test setup with port."""
config = dict(self.GOOD_CONFIG)
config[self.THING]['port'] = 6123
assert self.COMPONENT.setup(self.hass, config)
@@ -87,6 +90,7 @@ class TestMfiSensorSetup(unittest.TestCase):
@mock.patch('mficlient.client.MFiClient')
def test_setup_with_tls_disabled(self, mock_client):
"""Test setup without TLS."""
config = dict(self.GOOD_CONFIG)
del config[self.THING]['port']
config[self.THING]['use_tls'] = False
@@ -99,6 +103,7 @@ class TestMfiSensorSetup(unittest.TestCase):
@mock.patch('mficlient.client.MFiClient')
@mock.patch('homeassistant.components.sensor.mfi.MfiSensor')
def test_setup_adds_proper_devices(self, mock_sensor, mock_client):
"""Test if setup adds devices."""
ports = {i: mock.MagicMock(model=model)
for i, model in enumerate(mfi.SENSOR_MODELS)}
ports['bad'] = mock.MagicMock(model='notasensor')
@@ -113,7 +118,10 @@ class TestMfiSensorSetup(unittest.TestCase):
class TestMfiSensor(unittest.TestCase):
"""Test for mFi sensor platform."""
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.config.latitude = 32.87336
self.hass.config.longitude = 117.22743
@@ -121,29 +129,35 @@ class TestMfiSensor(unittest.TestCase):
self.sensor = mfi.MfiSensor(self.port, self.hass)
def teardown_method(self, method):
""" Stop down stuff we started. """
"""Stop everything that was started."""
self.hass.stop()
def test_name(self):
"""Test the name."""
self.assertEqual(self.port.label, self.sensor.name)
def test_uom_temp(self):
"""Test the UOM temperature."""
self.port.tag = 'temperature'
self.assertEqual(TEMP_CELCIUS, self.sensor.unit_of_measurement)
def test_uom_power(self):
"""Test the UOEM power."""
self.port.tag = 'active_pwr'
self.assertEqual('Watts', self.sensor.unit_of_measurement)
def test_uom_digital(self):
"""Test the UOM digital input."""
self.port.model = 'Input Digital'
self.assertEqual('State', self.sensor.unit_of_measurement)
def test_uom_unknown(self):
"""Test the UOM."""
self.port.tag = 'balloons'
self.assertEqual('balloons', self.sensor.unit_of_measurement)
def test_state_digital(self):
"""Test the digital input."""
self.port.model = 'Input Digital'
self.port.value = 0
self.assertEqual(mfi.STATE_OFF, self.sensor.state)
@@ -153,6 +167,7 @@ class TestMfiSensor(unittest.TestCase):
self.assertEqual(mfi.STATE_ON, self.sensor.state)
def test_state_digits(self):
"""Test the state of digits."""
self.port.tag = 'didyoucheckthedict?'
self.port.value = 1.25
with mock.patch.dict(mfi.DIGITS, {'didyoucheckthedict?': 1}):
@@ -161,5 +176,6 @@ class TestMfiSensor(unittest.TestCase):
self.assertEqual(1.0, self.sensor.state)
def test_update(self):
"""Test the update."""
self.sensor.update()
self.port.refresh.assert_called_once_with()
+6 -8
View File
@@ -1,9 +1,4 @@
"""
tests.components.sensor.test_mqtt
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests MQTT sensor.
"""
"""The tests for the MQTT sensor platform."""
import unittest
import homeassistant.components.sensor as sensor
@@ -13,17 +8,19 @@ from tests.common import get_test_home_assistant
class TestSensorMQTT(unittest.TestCase):
""" Test the MQTT sensor. """
"""Test the MQTT sensor."""
def setUp(self): # pylint: disable=invalid-name
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
mock_mqtt_component(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_setting_sensor_value_via_mqtt_message(self):
"""Test the setting of the value via MQTT."""
self.assertTrue(sensor.setup(self.hass, {
'sensor': {
'platform': 'mqtt',
@@ -42,6 +39,7 @@ class TestSensorMQTT(unittest.TestCase):
state.attributes.get('unit_of_measurement'))
def test_setting_sensor_value_via_mqtt_json_message(self):
"""Test the setting of the value via MQTT with JSON playload."""
self.assertTrue(sensor.setup(self.hass, {
'sensor': {
'platform': 'mqtt',
+14 -20
View File
@@ -1,10 +1,4 @@
"""
tests.components.sensor.test_rfxtrx
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Rfxtrx sensor.
"""
"""The tests for the Rfxtrx sensor platform."""
import unittest
@@ -16,25 +10,25 @@ from tests.common import get_test_home_assistant
class TestSensorRfxtrx(unittest.TestCase):
""" Test the Rfxtrx sensor. """
"""Test the Rfxtrx sensor 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 sensors """
"""Test with 0 sensor."""
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)
@@ -42,7 +36,7 @@ class TestSensorRfxtrx(unittest.TestCase):
self.assertEqual(0, len(devices))
def test_one_sensor(self):
""" Test with 1 sensor """
"""Test with 1 sensor."""
config = {'devices':
{'sensor_0502': {
'name': 'Test',
@@ -51,7 +45,7 @@ class TestSensorRfxtrx(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)
@@ -69,7 +63,7 @@ class TestSensorRfxtrx(unittest.TestCase):
entity.device_state_attributes)
def test_several_sensors(self):
""" Test with 3 sensors """
"""Test with 3 sensors."""
config = {'devices':
{'sensor_0502': {
'name': 'Test',
@@ -85,7 +79,7 @@ class TestSensorRfxtrx(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)
@@ -129,12 +123,12 @@ class TestSensorRfxtrx(unittest.TestCase):
self.assertEqual(3, device_num)
def test_discover_sensor(self):
""" Test with discover of sensor """
"""Test with discovery of sensor."""
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)
@@ -196,12 +190,12 @@ class TestSensorRfxtrx(unittest.TestCase):
self.assertEqual(2, len(devices))
def test_discover_sensor_noautoadd(self):
""" Test with discover of sensor when auto add is False """
"""Test with discover of sensor 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)
+27 -60
View File
@@ -1,9 +1,4 @@
"""
tests.components.sensor.tcp
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests TCP sensor.
"""
"""The tests for the TCP sensor platform."""
import socket
from copy import copy
from uuid import uuid4
@@ -37,7 +32,7 @@ KEYS_AND_DEFAULTS = {
@patch('homeassistant.components.sensor.tcp.Sensor.update')
def test_setup_platform_valid_config(mock_update):
""" Should check the supplied config and call add_entities with Sensor. """
"""Should check the supplied config and call add_entities with Sensor."""
add_entities = Mock()
ret = tcp.setup_platform(None, TEST_CONFIG, add_entities)
assert ret is None, "setup_platform() should return None if successful."
@@ -46,30 +41,32 @@ def test_setup_platform_valid_config(mock_update):
def test_setup_platform_invalid_config():
""" Should check the supplied config and return False if it is invalid. """
"""Should check the supplied config and return False if it is invalid."""
config = copy(TEST_CONFIG)
del config[tcp.CONF_HOST]
assert tcp.setup_platform(None, config, None) is False
class TestTCPSensor():
""" Test the TCP Sensor. """
"""Test the TCP Sensor."""
def setup_class(cls):
"""Setup things to be run when tests are started."""
cls.hass = get_test_home_assistant()
def teardown_class(cls):
"""Stop everything that was started."""
cls.hass.stop()
@patch('homeassistant.components.sensor.tcp.Sensor.update')
def test_name(self, mock_update):
""" Should return the name if set in the config. """
"""Should return the name if set in the config."""
sensor = tcp.Sensor(self.hass, TEST_CONFIG)
assert sensor.name == TEST_CONFIG[tcp.CONF_NAME]
@patch('homeassistant.components.sensor.tcp.Sensor.update')
def test_name_not_set(self, mock_update):
""" Should return the superclass name property if not set in config """
"""Should return the superclass name property if not set in config."""
config = copy(TEST_CONFIG)
del config[tcp.CONF_NAME]
entity = Entity()
@@ -78,7 +75,7 @@ class TestTCPSensor():
@patch('homeassistant.components.sensor.tcp.Sensor.update')
def test_state(self, mock_update):
""" Should return the contents of _state. """
"""Should return the contents of _state."""
sensor = tcp.Sensor(self.hass, TEST_CONFIG)
uuid = str(uuid4())
sensor._state = uuid
@@ -86,30 +83,24 @@ class TestTCPSensor():
@patch('homeassistant.components.sensor.tcp.Sensor.update')
def test_unit_of_measurement(self, mock_update):
""" Should return the configured unit of measurement. """
"""Should return the configured unit of measurement."""
sensor = tcp.Sensor(self.hass, TEST_CONFIG)
assert sensor.unit_of_measurement == TEST_CONFIG[tcp.CONF_UNIT]
@patch("homeassistant.components.sensor.tcp.Sensor.update")
def test_config_valid_keys(self, *args):
"""
Should store valid keys in _config.
"""
"""Should store valid keys in _config."""
sensor = tcp.Sensor(self.hass, TEST_CONFIG)
for key in TEST_CONFIG:
assert key in sensor._config
def test_validate_config_valid_keys(self):
"""
Should return True when provided with the correct keys.
"""
"""Should return True when provided with the correct keys."""
assert tcp.Sensor.validate_config(TEST_CONFIG)
@patch("homeassistant.components.sensor.tcp.Sensor.update")
def test_config_invalid_keys(self, mock_update):
"""
Shouldn't store invalid keys in _config.
"""
"""Shouldn't store invalid keys in _config."""
config = copy(TEST_CONFIG)
config.update({
"a": "test_a",
@@ -121,9 +112,7 @@ class TestTCPSensor():
assert invalid_key not in sensor._config
def test_validate_config_invalid_keys(self):
"""
Should return True when provided with the correct keys plus some extra.
"""
"""Test with invalid keys plus some extra."""
config = copy(TEST_CONFIG)
config.update({
"a": "test_a",
@@ -134,9 +123,7 @@ class TestTCPSensor():
@patch("homeassistant.components.sensor.tcp.Sensor.update")
def test_config_uses_defaults(self, mock_update):
"""
Should use defaults where appropriate.
"""
"""Should use defaults where appropriate."""
config = copy(TEST_CONFIG)
for key in KEYS_AND_DEFAULTS.keys():
del config[key]
@@ -145,18 +132,14 @@ class TestTCPSensor():
assert sensor._config[key] == default
def test_validate_config_missing_defaults(self):
"""
Should return True when defaulted keys are not provided.
"""
"""Should return True when defaulted keys are not provided."""
config = copy(TEST_CONFIG)
for key in KEYS_AND_DEFAULTS.keys():
del config[key]
assert tcp.Sensor.validate_config(config)
def test_validate_config_missing_required(self):
"""
Should return False when required config items are missing.
"""
"""Should return False when required config items are missing."""
for key in TEST_CONFIG:
if key in KEYS_AND_DEFAULTS:
continue
@@ -168,18 +151,14 @@ class TestTCPSensor():
@patch("homeassistant.components.sensor.tcp.Sensor.update")
def test_init_calls_update(self, mock_update):
"""
Should call update() method during __init__().
"""
"""Should call update() method during __init__()."""
tcp.Sensor(self.hass, TEST_CONFIG)
assert mock_update.called
@patch("socket.socket")
@patch("select.select", return_value=(True, False, False))
def test_update_connects_to_host_and_port(self, mock_select, mock_socket):
"""
Should connect to the configured host and port.
"""
"""Should connect to the configured host and port."""
tcp.Sensor(self.hass, TEST_CONFIG)
mock_socket = mock_socket().__enter__()
assert mock_socket.connect.mock_calls[0][1] == ((
@@ -188,9 +167,7 @@ class TestTCPSensor():
@patch("socket.socket.connect", side_effect=socket.error())
def test_update_returns_if_connecting_fails(self, *args):
"""
Should return if connecting to host fails.
"""
"""Should return if connecting to host fails."""
with patch("homeassistant.components.sensor.tcp.Sensor.update"):
sensor = tcp.Sensor(self.hass, TEST_CONFIG)
assert sensor.update() is None
@@ -198,9 +175,7 @@ class TestTCPSensor():
@patch("socket.socket.connect")
@patch("socket.socket.send", side_effect=socket.error())
def test_update_returns_if_sending_fails(self, *args):
"""
Should return if sending fails.
"""
"""Should return if sending fails."""
with patch("homeassistant.components.sensor.tcp.Sensor.update"):
sensor = tcp.Sensor(self.hass, TEST_CONFIG)
assert sensor.update() is None
@@ -209,7 +184,7 @@ class TestTCPSensor():
@patch("socket.socket.send")
@patch("select.select", return_value=(False, False, False))
def test_update_returns_if_select_fails(self, *args):
""" Should return if select fails to return a socket. """
"""Should return if select fails to return a socket."""
with patch("homeassistant.components.sensor.tcp.Sensor.update"):
sensor = tcp.Sensor(self.hass, TEST_CONFIG)
assert sensor.update() is None
@@ -217,9 +192,7 @@ class TestTCPSensor():
@patch("socket.socket")
@patch("select.select", return_value=(True, False, False))
def test_update_sends_payload(self, mock_select, mock_socket):
"""
Should send the configured payload as bytes.
"""
"""Should send the configured payload as bytes."""
tcp.Sensor(self.hass, TEST_CONFIG)
mock_socket = mock_socket().__enter__()
mock_socket.send.assert_called_with(
@@ -229,9 +202,7 @@ class TestTCPSensor():
@patch("socket.socket")
@patch("select.select", return_value=(True, False, False))
def test_update_calls_select_with_timeout(self, mock_select, mock_socket):
"""
Should provide the timeout argument to select.
"""
"""Should provide the timeout argument to select."""
tcp.Sensor(self.hass, TEST_CONFIG)
mock_socket = mock_socket().__enter__()
mock_select.assert_called_with(
@@ -241,9 +212,7 @@ class TestTCPSensor():
@patch("select.select", return_value=(True, False, False))
def test_update_receives_packet_and_sets_as_state(
self, mock_select, mock_socket):
"""
Should receive the response from the socket and set it as the state.
"""
"""Test the response from the socket and set it as the state."""
test_value = "test_value"
mock_socket = mock_socket().__enter__()
mock_socket.recv.return_value = test_value.encode()
@@ -255,9 +224,7 @@ class TestTCPSensor():
@patch("socket.socket")
@patch("select.select", return_value=(True, False, False))
def test_update_renders_value_in_template(self, mock_select, mock_socket):
"""
Should render the value in the provided template.
"""
"""Should render the value in the provided template."""
test_value = "test_value"
mock_socket = mock_socket().__enter__()
mock_socket.recv.return_value = test_value.encode()
@@ -270,7 +237,7 @@ class TestTCPSensor():
@patch("select.select", return_value=(True, False, False))
def test_update_returns_if_template_render_fails(
self, mock_select, mock_socket):
""" Should return None if rendering the template fails. """
"""Should return None if rendering the template fails."""
test_value = "test_value"
mock_socket = mock_socket().__enter__()
mock_socket.recv.return_value = test_value.encode()
+11 -8
View File
@@ -1,25 +1,22 @@
"""
tests.components.sensor.test_template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests template sensor.
"""
"""The test for the Template sensor platform."""
import homeassistant.components.sensor as sensor
from tests.common import get_test_home_assistant
class TestTemplateSensor:
""" Test the Template sensor. """
"""Test the Template sensor."""
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
def teardown_method(self, method):
""" Stop down stuff we started. """
"""Stop everything that was started."""
self.hass.stop()
def test_template(self):
"""Test template."""
assert sensor.setup(self.hass, {
'sensor': {
'platform': 'template',
@@ -41,6 +38,7 @@ class TestTemplateSensor:
assert state.state == 'It Works.'
def test_template_syntax_error(self):
"""Test templating syntax error."""
assert sensor.setup(self.hass, {
'sensor': {
'platform': 'template',
@@ -59,6 +57,7 @@ class TestTemplateSensor:
assert state.state == 'error'
def test_template_attribute_missing(self):
"""Test missing attribute template."""
assert sensor.setup(self.hass, {
'sensor': {
'platform': 'template',
@@ -75,6 +74,7 @@ class TestTemplateSensor:
assert state.state == 'error'
def test_invalid_name_does_not_create(self):
"""Test invalid name."""
assert sensor.setup(self.hass, {
'sensor': {
'platform': 'template',
@@ -89,6 +89,7 @@ class TestTemplateSensor:
assert self.hass.states.all() == []
def test_invalid_sensor_does_not_create(self):
"""Test invalid sensor."""
assert sensor.setup(self.hass, {
'sensor': {
'platform': 'template',
@@ -100,6 +101,7 @@ class TestTemplateSensor:
assert self.hass.states.all() == []
def test_no_sensors_does_not_create(self):
"""Test no sensors."""
assert sensor.setup(self.hass, {
'sensor': {
'platform': 'template'
@@ -108,6 +110,7 @@ class TestTemplateSensor:
assert self.hass.states.all() == []
def test_missing_template_does_not_create(self):
"""Test missing template."""
assert sensor.setup(self.hass, {
'sensor': {
'platform': 'template',
+6 -8
View File
@@ -1,9 +1,4 @@
"""
tests.components.sensor.test_yr
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tests Yr sensor.
"""
"""The tests for the Yr sensor platform."""
from datetime import datetime
from unittest.mock import patch
@@ -17,18 +12,20 @@ from tests.common import get_test_home_assistant
@pytest.mark.usefixtures('betamax_session')
class TestSensorYr:
""" Test the Yr sensor. """
"""Test the Yr sensor."""
def setup_method(self, method):
"""Setup things to be run when tests are started."""
self.hass = get_test_home_assistant()
self.hass.config.latitude = 32.87336
self.hass.config.longitude = 117.22743
def teardown_method(self, method):
""" Stop down stuff we started. """
"""Stop everything that was started."""
self.hass.stop()
def test_default_setup(self, betamax_session):
"""Test the default setup."""
now = datetime(2016, 1, 5, 1, tzinfo=dt_util.UTC)
with patch('homeassistant.components.sensor.yr.requests.Session',
@@ -49,6 +46,7 @@ class TestSensorYr:
assert state.attributes.get('unit_of_measurement') is None
def test_custom_setup(self, betamax_session):
"""Test a custom setup."""
now = datetime(2016, 1, 5, 1, tzinfo=dt_util.UTC)
with patch('homeassistant.components.sensor.yr.requests.Session',