From 8f12b997f8c61ab21fb1536c3668c8ed40b4e73e Mon Sep 17 00:00:00 2001 From: hexxter Date: Wed, 11 Nov 2015 12:32:24 +0100 Subject: [PATCH] more unittests --- tests/components/light/test_mqtt.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/components/light/test_mqtt.py b/tests/components/light/test_mqtt.py index 0d97b61441c..d1678f8cee1 100644 --- a/tests/components/light/test_mqtt.py +++ b/tests/components/light/test_mqtt.py @@ -44,6 +44,7 @@ light: payload_off: "off" """ import unittest +import homeassistant.util.color as color_util from homeassistant.const import STATE_ON, STATE_OFF import homeassistant.core as ha @@ -93,13 +94,25 @@ class TestLightMQTT(unittest.TestCase): state = self.hass.states.get('light.test') self.assertEqual(STATE_OFF, state.state) + + fire_mqtt_message(self.hass, 'test_light_rgb/status', 'on') + self.hass.pool.block_till_done() fire_mqtt_message(self.hass, 'test_light_rgb/brightness/status', '100') self.hass.pool.block_till_done() light_state = self.hass.states.get('light.test') self.assertEqual(100, - light_state.attributes) + light_state.attributes['brightness']) + self.assertEqual([0, 0], + light_state.attributes['xy_color']) + xy = color_util.color_RGB_to_xy(125,125,125) + fire_mqtt_message(self.hass, 'test_light_rgb/rgb/status', '125,125,125') + self.hass.pool.block_till_done() + + light_state = self.hass.states.get('light.test') + self.assertEqual(xy, + light_state.attributes['xy_color']) def test_sending_mqtt_commands_and_optimistic(self): self.assertTrue(light.setup(self.hass, {