test_bcom_intercom_camera.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. """Tests for the bcom intercom camera"""
  2. from ..const import BCOM_CAMERA_PAYLOAD
  3. from .base_device_tests import TuyaDeviceTestCase
  4. LIGHT_DPS = "101"
  5. FLIP_DPS = "103"
  6. WATERMARK_DPS = "104"
  7. MOTION_DPS = "106"
  8. NIGHT_DPS = "108"
  9. SDSIZE_DPS = "109"
  10. SDSTATUS_DPS = "110"
  11. SDFORMAT_DPS = "111"
  12. SNAPSHOT_DPS = "115"
  13. SDFMTSTATE_DPS = "117"
  14. DOORBELL_DPS = "154"
  15. RECORD_DPS = "150"
  16. RECMODE_DPS = "151"
  17. REBOOT_DPS = "162"
  18. CHANNEL_DPS = "231"
  19. LOCK_DPS = "232"
  20. class TestBcomIntercomCamera(TuyaDeviceTestCase):
  21. __test__ = True
  22. def setUp(self):
  23. self.setUpForConfig("bcom_intercom_camera.yaml", BCOM_CAMERA_PAYLOAD)
  24. self.subject = self.entities.get("camera")
  25. self.mark_secondary(
  26. [
  27. "light_indicator",
  28. "switch_flip_image",
  29. "switch_watermark",
  30. "select_motion_sensitivity",
  31. "select_night_vision",
  32. "sensor_sd_capacity",
  33. "sensor_sd_status",
  34. "button_sd_format",
  35. "sensor_sd_format_state",
  36. "select_recording_mode",
  37. "button_restart",
  38. "sensor_channel",
  39. ]
  40. )
  41. def test_is_recording(self):
  42. self.dps[RECORD_DPS] = True
  43. self.assertTrue(self.subject.is_recording)
  44. self.dps[RECORD_DPS] = False
  45. self.assertFalse(self.subject.is_recording)
  46. def test_motion_detection_enabled(self):
  47. self.assertIsNone(self.subject.motion_detection_enabled)
  48. def test_is_on(self):
  49. self.assertIsNone(self.subject.is_on)
  50. async def test_camera_image(self):
  51. self.dps[DOORBELL_DPS] = ""
  52. self.dps[SNAPSHOT_DPS] = "VGVzdA=="
  53. image = await self.subject.async_camera_image()
  54. self.assertEqual(image, b"Test")
  55. self.dps[DOORBELL_DPS] = "a25vY2sga25vY2s="
  56. image = await self.subject.async_camera_image()
  57. self.assertEqual(image, b"knock knock")
  58. async def test_turn_off(self):
  59. with self.assertRaises(NotImplementedError):
  60. await self.subject.async_turn_off()
  61. async def test_turn_on(self):
  62. with self.assertRaises(NotImplementedError):
  63. await self.subject.async_turn_on()