test_avatto_curtain_switch.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. __test__ = True
  11. def setUp(self):
  12. self.setUpForConfig(
  13. "avatto_curtain_switch.yaml",
  14. AVATTO_CURTAIN_PAYLOAD,
  15. )
  16. self.subject = self.entities.get("cover_curtain")
  17. self.setUpBasicLight(
  18. BACKLIGHT_DP,
  19. self.entities.get("light_backlight"),
  20. )
  21. self.mark_secondary(["light_backlight"])
  22. def test_device_class_is_curtain(self):
  23. self.assertEqual(self.subject.device_class, CoverDeviceClass.CURTAIN)
  24. def test_supported_features(self):
  25. self.assertEqual(
  26. self.subject.supported_features,
  27. (
  28. CoverEntityFeature.OPEN
  29. | CoverEntityFeature.CLOSE
  30. | CoverEntityFeature.STOP
  31. ),
  32. )
  33. def test_is_opening(self):
  34. self.assertIsNone(self.subject.is_opening)
  35. def test_is_closing(self):
  36. self.assertIsNone(self.subject.is_closing)
  37. def test_is_closed(self):
  38. self.assertIsNone(self.subject.is_closed)
  39. async def test_open_cover(self):
  40. async with assert_device_properties_set(
  41. self.subject._device,
  42. {COMMAND_DP: "open"},
  43. ):
  44. await self.subject.async_open_cover()
  45. async def test_close_cover(self):
  46. async with assert_device_properties_set(
  47. self.subject._device,
  48. {COMMAND_DP: "close"},
  49. ):
  50. await self.subject.async_close_cover()
  51. async def test_stop_cover(self):
  52. async with assert_device_properties_set(
  53. self.subject._device,
  54. {COMMAND_DP: "stop"},
  55. ):
  56. await self.subject.async_stop_cover()