Просмотр исходного кода

Add light color_mode tests to fill out unit testing coverage.

Fix minor typo in log message.
Jason Rumney 4 лет назад
Родитель
Сommit
1a59582dd1

+ 1 - 1
custom_components/tuya_local/__init__.py

@@ -110,7 +110,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
     setup_device(hass, config)
     device_conf = get_config(config[CONF_TYPE])
     if device_conf is None:
-        _LOGGER.error(f"COnfiguration file for {config[CONF_TYPE]} not found.")
+        _LOGGER.error(f"Configuration file for {config[CONF_TYPE]} not found.")
         return False
 
     entities = {}

+ 5 - 3
tests/devices/test_deta_fan.py

@@ -1,6 +1,5 @@
-from homeassistant.components.fan import (
-    SUPPORT_SET_SPEED,
-)
+from homeassistant.components.fan import SUPPORT_SET_SPEED
+from homeassistant.components.light import COLOR_MODE_ONOFF
 
 from homeassistant.const import STATE_UNAVAILABLE
 
@@ -80,6 +79,9 @@ class TestDetaFan(TuyaDeviceTestCase):
         self.assertEqual(self.subject.device_state_attributes, {"timer": 5})
         self.assertEqual(self.light.device_state_attributes, {"timer": 6})
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_is_on(self):
         self.dps[LIGHT_DPS] = True
         self.assertTrue(self.light.is_on)

+ 4 - 0
tests/devices/test_electriq_12wminv_heatpump.py

@@ -9,6 +9,7 @@ from homeassistant.components.climate.const import (
     SUPPORT_SWING_MODE,
     SUPPORT_TARGET_TEMPERATURE,
 )
+from homeassistant.components.light import COLOR_MODE_ONOFF
 from homeassistant.const import STATE_UNAVAILABLE
 
 from ..const import ELECTRIQ_12WMINV_HEATPUMP_PAYLOAD
@@ -306,6 +307,9 @@ class TestElectriq12WMINVHeatpump(TuyaDeviceTestCase):
     def test_light_state_attributes(self):
         self.assertEqual(self.light.device_state_attributes, {})
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_is_on(self):
         self.dps[LIGHT_DPS] = True
         self.assertTrue(self.light.is_on)

+ 4 - 0
tests/devices/test_electriq_cd20_dehumidifier.py

@@ -1,5 +1,6 @@
 from homeassistant.components.fan import SUPPORT_PRESET_MODE
 from homeassistant.components.humidifier import SUPPORT_MODES
+from homeassistant.components.light import COLOR_MODE_ONOFF
 from homeassistant.const import STATE_UNAVAILABLE
 
 from ..const import ELECTRIQ_CD20PRO_DEHUMIDIFIER_PAYLOAD
@@ -208,6 +209,9 @@ class TestElectriqCD20ProDehumidifier(TuyaDeviceTestCase):
             await self.fan.async_set_preset_mode("Oscillate")
             self.subject._device.anticipate_property_value.assert_not_called()
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_is_on(self):
         self.dps[LIGHT_DPS] = True
         self.assertTrue(self.light.is_on)

+ 4 - 0
tests/devices/test_electriq_cd25_dehumidifier.py

@@ -1,5 +1,6 @@
 from homeassistant.components.fan import SUPPORT_PRESET_MODE
 from homeassistant.components.humidifier import SUPPORT_MODES
+from homeassistant.components.light import COLOR_MODE_ONOFF
 from homeassistant.const import STATE_UNAVAILABLE
 
 from ..const import ELECTRIQ_DEHUMIDIFIER_PAYLOAD
@@ -224,6 +225,9 @@ class TestElectriqCD25ProDehumidifier(TuyaDeviceTestCase):
         async with assert_device_properties_set(self.lock._device, {LOCK_DPS: False}):
             await self.lock.async_unlock()
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_is_on(self):
         self.dps[LIGHT_DPS] = True
         self.assertTrue(self.light.is_on)

+ 4 - 0
tests/devices/test_goldair_dehumidifier.py

@@ -10,6 +10,7 @@ from homeassistant.components.climate.const import (
     SUPPORT_PRESET_MODE,
     SUPPORT_TARGET_HUMIDITY,
 )
+from homeassistant.components.light import COLOR_MODE_ONOFF
 from homeassistant.components.lock import STATE_LOCKED, STATE_UNLOCKED
 from homeassistant.const import STATE_UNAVAILABLE
 
@@ -582,6 +583,9 @@ class TestGoldairDehumidifier(TuyaDeviceTestCase):
         async with assert_device_properties_set(self.lock._device, {LOCK_DPS: False}):
             await self.lock.async_unlock()
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_icon(self):
         self.dps[LIGHTOFF_DPS] = False
         self.assertEqual(self.light.icon, "mdi:led-on")

+ 4 - 0
tests/devices/test_goldair_fan.py

@@ -14,6 +14,7 @@ from homeassistant.components.fan import (
     SUPPORT_PRESET_MODE,
     SUPPORT_SET_SPEED,
 )
+from homeassistant.components.light import COLOR_MODE_ONOFF
 
 from homeassistant.const import STATE_UNAVAILABLE
 
@@ -319,6 +320,9 @@ class TestGoldairFan(TuyaDeviceTestCase):
         self.assertEqual(self.climate.device_state_attributes, {"timer": "5"})
         self.assertEqual(self.subject.device_state_attributes, {"timer": "5"})
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_icon(self):
         self.dps[LIGHT_DPS] = True
         self.assertEqual(self.light.icon, "mdi:led-on")

+ 4 - 0
tests/devices/test_goldair_gpph_heater.py

@@ -7,6 +7,7 @@ from homeassistant.components.climate.const import (
     SUPPORT_SWING_MODE,
     SUPPORT_TARGET_TEMPERATURE,
 )
+from homeassistant.components.light import COLOR_MODE_ONOFF
 from homeassistant.components.lock import STATE_LOCKED, STATE_UNLOCKED
 
 from homeassistant.const import STATE_UNAVAILABLE
@@ -345,6 +346,9 @@ class TestGoldairHeater(TuyaDeviceTestCase):
         async with assert_device_properties_set(self.lock._device, {LOCK_DPS: False}):
             await self.lock.async_unlock()
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_icon(self):
         self.dps[LIGHT_DPS] = True
         self.assertEqual(self.light.icon, "mdi:led-on")

+ 4 - 0
tests/devices/test_lexy_f501_fan.py

@@ -3,6 +3,7 @@ from homeassistant.components.fan import (
     SUPPORT_PRESET_MODE,
     SUPPORT_SET_SPEED,
 )
+from homeassistant.components.light import COLOR_MODE_ONOFF
 from homeassistant.components.lock import STATE_LOCKED, STATE_UNLOCKED
 from homeassistant.const import STATE_UNAVAILABLE
 
@@ -153,6 +154,9 @@ class TestLexyF501Fan(TuyaDeviceTestCase):
         self.dps[TIMER_DPS] = "5"
         self.assertEqual(self.subject.device_state_attributes, {"timer": 5})
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_is_on(self):
         self.dps[LIGHT_DPS] = True
         self.assertEqual(self.light.is_on, True)

+ 4 - 0
tests/devices/test_purline_m100_heater.py

@@ -8,6 +8,7 @@ from homeassistant.components.climate.const import (
     SWING_OFF,
     SWING_VERTICAL,
 )
+from homeassistant.components.light import COLOR_MODE_ONOFF
 from homeassistant.components.switch import DEVICE_CLASS_SWITCH
 from homeassistant.const import STATE_UNAVAILABLE
 
@@ -206,6 +207,9 @@ class TestPulineM100Heater(TuyaDeviceTestCase):
         ):
             await self.subject.async_set_swing_mode(SWING_OFF)
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_ONOFF)
+
     def test_light_icon(self):
         self.dps[LIGHTOFF_DPS] = False
         self.assertEqual(self.light.icon, "mdi:led-on")

+ 4 - 1
tests/devices/test_wetair_wch750_heater.py

@@ -7,7 +7,7 @@ from homeassistant.components.climate.const import (
     SUPPORT_PRESET_MODE,
     SUPPORT_TARGET_TEMPERATURE,
 )
-
+from homeassistant.components.light import COLOR_MODE_BRIGHTNESS
 from homeassistant.const import STATE_UNAVAILABLE
 
 from ..const import WETAIR_WCH750_HEATER_PAYLOAD
@@ -203,6 +203,9 @@ class TestWetairWCH750Heater(TuyaDeviceTestCase):
             },
         )
 
+    def test_light_color_mode(self):
+        self.assertEqual(self.light.color_mode, COLOR_MODE_BRIGHTNESS)
+
     def test_light_is_on(self):
         self.dps[BRIGHTNESS_DPS] = "level0"
         self.assertEqual(self.light.is_on, False)