test_simple_switch_with_timerv2.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. """Tests for a simple switch with timer"""
  2. from ..const import TIMED_SOCKETV2_PAYLOAD
  3. from ..mixins.switch import SwitchableTests
  4. from .base_device_tests import TuyaDeviceTestCase
  5. SWITCH_DPS = "1"
  6. TIMER_DPS = "9"
  7. INITIAL_STATE_DPS = "38"
  8. class TestTimedSwitch(SwitchableTests, TuyaDeviceTestCase):
  9. def setUp(self):
  10. self.setUpForConfig("simple_switch_timerv2.yaml", TIMED_SOCKETV2_PAYLOAD)
  11. self.subject = self.entities.get("switch")
  12. self.setUpSwitchable(SWITCH_DPS, self.subject)
  13. self.mark_secondary(
  14. [
  15. "select_initial_state",
  16. "time_timer",
  17. ]
  18. )
  19. def test_extra_state_attributes_set(self):
  20. self.assertDictEqual(
  21. self.subject.extra_state_attributes,
  22. {},
  23. )
  24. def test_available(self):
  25. for id, e in self.entities.items():
  26. if id == "select_initial_state":
  27. self.dps[INITIAL_STATE_DPS] = None
  28. self.assertFalse(e.available)
  29. self.dps[INITIAL_STATE_DPS] = "on"
  30. self.assertTrue(e.available)