test_avatto_curtain_switch.py 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. """Tests for the Avatto roller blinds controller."""
  2. from homeassistant.components.cover import CoverDeviceClass, CoverEntityFeature
  3. from ..const import AVATTO_CURTAIN_PAYLOAD
  4. from ..helpers import assert_device_properties_set
  5. from ..mixins.light import BasicLightTests
  6. from .base_device_tests import TuyaDeviceTestCase
  7. COMMAND_DP = "1"
  8. BACKLIGHT_DP = "101"
  9. class TestAvattoCurtainSwitch(BasicLightTests, TuyaDeviceTestCase):
  10. def setUp(self):
  11. self.setUpForConfig(
  12. "avatto_curtain_switch.yaml",
  13. AVATTO_CURTAIN_PAYLOAD,
  14. )
  15. self.subject = self.entities.get("cover_curtain")
  16. self.setUpBasicLight(
  17. BACKLIGHT_DP,
  18. self.entities.get("light_backlight"),
  19. )
  20. self.mark_secondary(["light_backlight"])
  21. def test_device_class_is_curtain(self):
  22. self.assertEqual(self.subject.device_class, CoverDeviceClass.CURTAIN)
  23. def test_supported_features(self):
  24. self.assertEqual(
  25. self.subject.supported_features,
  26. (
  27. CoverEntityFeature.OPEN
  28. | CoverEntityFeature.CLOSE
  29. | CoverEntityFeature.STOP
  30. ),
  31. )
  32. def test_is_opening(self):
  33. self.assertIsNone(self.subject.is_opening)
  34. def test_is_closing(self):
  35. self.assertIsNone(self.subject.is_closing)
  36. def test_is_closed(self):
  37. self.assertIsNone(self.subject.is_closed)
  38. async def test_open_cover(self):
  39. async with assert_device_properties_set(
  40. self.subject._device,
  41. {COMMAND_DP: "open"},
  42. ):
  43. await self.subject.async_open_cover()
  44. async def test_close_cover(self):
  45. async with assert_device_properties_set(
  46. self.subject._device,
  47. {COMMAND_DP: "close"},
  48. ):
  49. await self.subject.async_close_cover()
  50. async def test_stop_cover(self):
  51. async with assert_device_properties_set(
  52. self.subject._device,
  53. {COMMAND_DP: "stop"},
  54. ):
  55. await self.subject.async_stop_cover()