test_simple_switch_with_timerv2.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. __test__ = True
  10. def setUp(self):
  11. self.setUpForConfig("simple_switch_timerv2.yaml", TIMED_SOCKETV2_PAYLOAD)
  12. self.subject = self.entities.get("switch")
  13. self.setUpSwitchable(SWITCH_DPS, self.subject)
  14. self.mark_secondary(
  15. [
  16. "select_initial_state",
  17. "time_timer",
  18. ]
  19. )
  20. def test_extra_state_attributes_set(self):
  21. self.assertDictEqual(
  22. self.subject.extra_state_attributes,
  23. {},
  24. )
  25. def test_available(self):
  26. for id, e in self.entities.items():
  27. if id == "select_initial_state":
  28. self.dps[INITIAL_STATE_DPS] = None
  29. self.assertFalse(e.available)
  30. self.dps[INITIAL_STATE_DPS] = "on"
  31. self.assertTrue(e.available)