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

tests: improve coverage for setting via value_redirect

- new test for Duux Blizaard tests to test conditional redirected temperature
- new test for SmartplugV2 Energy to test unconditional redirected switch

These tests should avoid regressions causing issues like noted in post
release comment on #3987
Jason Rumney 2 месяцев назад
Родитель
Сommit
b1d22dce8e
2 измененных файлов с 28 добавлено и 0 удалено
  1. 8 0
      tests/devices/test_duux_blizzard.py
  2. 20 0
      tests/devices/test_smartplugv2_energy.py

+ 8 - 0
tests/devices/test_duux_blizzard.py

@@ -82,3 +82,11 @@ class TestDuuxBlizzard(TargetTemperatureTests, TuyaDeviceTestCase):
         self.assertFalse(self.ionizer.available)
         self.dps[IONSHOW_DP] = True
         self.assertTrue(self.ionizer.available)
+
+    async def test_set_redirected_temperature(self):
+        self.dps[UNIT_DP] = True  # Fahrenheit
+        async with assert_device_properties_set(
+            self.subject._device,
+            {SETTEMPF_DP: 75},
+        ):
+            await self.subject.async_set_target_temperature(75)

+ 20 - 0
tests/devices/test_smartplugv2_energy.py

@@ -38,6 +38,7 @@ LOCK_DPS = "40"
 CYCLE_DPS = "41"
 RANDOM_DPS = "42"
 OVERCHARGE_DPS = "46"
+ALT_OVERCHARGE_DPS = "51"
 
 
 class TestSwitchV2Energy(
@@ -177,8 +178,27 @@ class TestSwitchV2Energy(
             {"fault_code": 2},
         )
 
+    async def test_redirected_switch(self):
+        overcharge_switch = self.multiSwitch["switch_overcharge_cutoff"]
+        self.dps[OVERCHARGE_DPS] = None
+        self.dps[ALT_OVERCHARGE_DPS] = False
+        async with assert_device_properties_set(
+            overcharge_switch._device,
+            {ALT_OVERCHARGE_DPS: True},
+        ):
+            await overcharge_switch.async_turn_on()
+
     def test_available(self):
         self.dps[INITIAL_DPS] = None
         self.assertFalse(self.basicSelect.available)
         self.dps[INITIAL_DPS] = "on"
         self.assertTrue(self.basicSelect.available)
+        self.dps[OVERCHARGE_DPS] = None
+        self.dps[ALT_OVERCHARGE_DPS] = None
+        overcharge_switch = self.multiSwitch["switch_overcharge_cutoff"]
+        self.assertFalse(overcharge_switch.available)
+        self.dps[ALT_OVERCHARGE_DPS] = False
+        self.assertTrue(overcharge_switch.available)
+        self.dps[ALT_OVERCHARGE_DPS] = None
+        self.dps[OVERCHARGE_DPS] = True
+        self.assertTrue(overcharge_switch.available)