فهرست منبع

water_heater: implement tests for away_mode and turn_on/off

- turning away mode off should not fail silently when there is no away mode.
Jason Rumney 2 سال پیش
والد
کامیت
ae5784dbfe
2فایلهای تغییر یافته به همراه27 افزوده شده و 0 حذف شده
  1. 2 0
      custom_components/tuya_local/water_heater.py
  2. 25 0
      tests/devices/test_hydrotherm_dynamicx8.py

+ 2 - 0
custom_components/tuya_local/water_heater.py

@@ -186,6 +186,8 @@ class TuyaLocalWaterHeater(TuyaLocalEntity, WaterHeaterEntity):
         ):
             # switch to the default mode
             await self.async_set_operation_mode(self._operation_mode_dps.default)
+        else:
+            raise NotImplementedError()
 
     @property
     def min_temp(self):

+ 25 - 0
tests/devices/test_hydrotherm_dynamicx8.py

@@ -98,6 +98,9 @@ class TestHydrothermDynamicX8(
         self.dps[POWER_DP] = False
         self.assertEqual(self.subject.current_operation, STATE_OFF)
 
+    def test_is_away_mode_is_none_when_unsupported(self):
+        self.assertIsNone(self.subject.is_away_mode_on)
+
     async def test_set_temperature_fails(self):
         with self.assertRaises(TypeError):
             await self.subject.async_set_temperature(temperature=65)
@@ -150,3 +153,25 @@ class TestHydrothermDynamicX8(
             {POWER_DP: False},
         ):
             await self.subject.async_set_operation_mode(STATE_OFF)
+
+    async def test_turn_on(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {POWER_DP: True},
+        ):
+            await self.subject.async_turn_on()
+
+    async def test_turn_off(self):
+        async with assert_device_properties_set(
+            self.subject._device,
+            {POWER_DP: False},
+        ):
+            await self.subject.async_turn_off()
+
+    async def test_turn_away_mode_on_fails(self):
+        with self.assertRaises(NotImplementedError):
+            await self.subject.async_turn_away_mode_on()
+
+    async def test_turn_away_mode_off_fails(self):
+        with self.assertRaises(NotImplementedError):
+            await self.subject.async_turn_away_mode_off()