test_treatlife_ds02f.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from homeassistant.components.fan import FanEntityFeature
  2. from ..const import TREATLIFE_DS02F_PAYLOAD
  3. from ..helpers import assert_device_properties_set
  4. from ..mixins.switch import SwitchableTests
  5. from .base_device_tests import TuyaDeviceTestCase
  6. SWITCH_DPS = "1"
  7. TIMER_DPS = "2"
  8. SPEED_DPS = "3"
  9. class TestTreatlifeFan(SwitchableTests, TuyaDeviceTestCase):
  10. def setUp(self):
  11. self.setUpForConfig("treatlife_ds02_fan.yaml", TREATLIFE_DS02F_PAYLOAD)
  12. self.subject = self.entities["fan"]
  13. self.setUpSwitchable(SWITCH_DPS, self.subject)
  14. self.mark_secondary(["time_timer"])
  15. def test_supported_features(self):
  16. self.assertEqual(
  17. self.subject.supported_features,
  18. FanEntityFeature.SET_SPEED
  19. | FanEntityFeature.TURN_ON
  20. | FanEntityFeature.TURN_OFF,
  21. )
  22. def test_speed(self):
  23. self.dps[SPEED_DPS] = "level_2"
  24. self.assertEqual(self.subject.percentage, 50)
  25. def test_speed_step(self):
  26. self.assertEqual(self.subject.percentage_step, 25)
  27. self.assertEqual(self.subject.speed_count, 4)
  28. async def test_set_speed(self):
  29. async with assert_device_properties_set(
  30. self.subject._device, {SPEED_DPS: "level_3"}
  31. ):
  32. await self.subject.async_set_percentage(75)
  33. async def test_set_speed_snaps(self):
  34. async with assert_device_properties_set(
  35. self.subject._device, {SPEED_DPS: "level_1"}
  36. ):
  37. await self.subject.async_set_percentage(30)