fix pep8 errors and typos in tests.

This commit is contained in:
Ryan Spicer
2016-09-18 22:43:04 -07:00
parent 559d1752d2
commit e61dda4dd3
2 changed files with 11 additions and 11 deletions

View File

@@ -11,11 +11,11 @@ import voluptuous as vol
import homeassistant.components.mqtt as mqtt
from homeassistant.components.light import (
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_COLOR_TEMP, SUPPORT_BRIGHTNESS,
ATTR_BRIGHTNESS, ATTR_RGB_COLOR, ATTR_COLOR_TEMP, SUPPORT_BRIGHTNESS,
SUPPORT_RGB_COLOR, SUPPORT_COLOR_TEMP, Light)
from homeassistant.const import (
CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE, CONF_PAYLOAD_OFF,
CONF_PAYLOAD_ON, CONF_STATE, CONF_BRIGHTNESS, CONF_RGB,
CONF_PAYLOAD_ON, CONF_STATE, CONF_BRIGHTNESS, CONF_RGB,
CONF_COLOR_TEMP)
from homeassistant.components.mqtt import (
CONF_STATE_TOPIC, CONF_COMMAND_TOPIC, CONF_QOS, CONF_RETAIN)
@@ -129,7 +129,7 @@ class MqttLight(Light):
topic[CONF_BRIGHTNESS_STATE_TOPIC] is not None
and SUPPORT_BRIGHTNESS)
self._supported_features |= (
topic[CONF_COLOR_TEMP_STATE_TOPIC] is not None
topic[CONF_COLOR_TEMP_STATE_TOPIC] is not None
and SUPPORT_COLOR_TEMP)
templates = {key: ((lambda value: value) if tpl is None else
@@ -210,7 +210,6 @@ class MqttLight(Light):
@property
def color_temp(self):
return self._color_temp
@property
def should_poll(self):

View File

@@ -186,9 +186,9 @@ class TestLightMQTT(unittest.TestCase):
self.assertEqual(100,
light_state.attributes['brightness'])
fire_mqtt_message(self.hass, 'test_lgith_rgb/color_temp/status', '300')
fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status', '300')
self.hass.block_till_done()
light_state = self.hass.states.get('light-test')
light_state = self.hass.states.get('light.test')
self.hass.block_till_done()
self.assertEqual(300, light_state.attributes['color_temp'])
@@ -260,6 +260,7 @@ class TestLightMQTT(unittest.TestCase):
'state_topic': 'test_light_rgb/status',
'command_topic': 'test_light_rgb/set',
'brightness_state_topic': 'test_light_rgb/brightness/status',
'color_temp_state_topic': 'test_light_rgb/color_temp/status',
'rgb_state_topic': 'test_light_rgb/rgb/status',
'state_value_template': '{{ value_json.hello }}',
'brightness_value_template': '{{ value_json.hello }}',
@@ -280,7 +281,7 @@ class TestLightMQTT(unittest.TestCase):
fire_mqtt_message(self.hass, 'test_light_rgb/brightness/status',
'{"hello": "50"}')
fire_mqtt_message(self.hass, 'test_light_rgb/color_temp/status',
'{"hello": "300}')
'{"hello": "300"}')
self.hass.block_till_done()
state = self.hass.states.get('light.test')
@@ -377,15 +378,15 @@ class TestLightMQTT(unittest.TestCase):
"""Test the color temp only if a command topic is present."""
self.hass.config.components = ['mqtt']
assert _setup_component(self.hass, light.DOMAIN, {
light.DOMAIN:{
light.DOMAIN: {
'platform': 'mqtt',
'name': 'test',
'color_temp_command_topic': 'test_light_rgb/brightness/set',
'command_topic': 'test_light_rgb/set',
'state_topic': 'test_light_rgb/status'
}
})
})
state = self.hass.states.get('light.test')
self.assertEqual(STATE_OFF, state.state)
self.assertIsNone(state.attributes.get('color_temp'))
@@ -395,4 +396,4 @@ class TestLightMQTT(unittest.TestCase):
state = self.hass.states.get('light.test')
self.assertEqual(STATE_ON, state.state)
self.assertEqual(150, state.attributes.get('color_temp'))
self.assertEqual(150, state.attributes.get('color_temp'))