test_bcom_intercom_camera.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. def setUp(self):
  22. self.setUpForConfig("bcom_intercom_camera.yaml", BCOM_CAMERA_PAYLOAD)
  23. self.subject = self.entities.get("camera")
  24. self.mark_secondary(
  25. [
  26. "light_indicator",
  27. "switch_flip_image",
  28. "switch_watermark",
  29. "select_motion_sensitivity",
  30. "select_night_vision",
  31. "sensor_sd_capacity",
  32. "sensor_sd_status",
  33. "button_sd_format",
  34. "sensor_sd_format_state",
  35. "select_recording_mode",
  36. "button_restart",
  37. "sensor_channel",
  38. ]
  39. )
  40. def test_is_recording(self):
  41. self.dps[RECORD_DPS] = True
  42. self.assertTrue(self.subject.is_recording)
  43. self.dps[RECORD_DPS] = False
  44. self.assertFalse(self.subject.is_recording)
  45. def test_motion_detection_enabled(self):
  46. self.assertIsNone(self.subject.motion_detection_enabled)
  47. def test_is_on(self):
  48. self.assertIsNone(self.subject.is_on)
  49. async def test_camera_image(self):
  50. self.dps[DOORBELL_DPS] = ""
  51. self.dps[SNAPSHOT_DPS] = "VGVzdA=="
  52. image = await self.subject.async_camera_image()
  53. self.assertEqual(image, b"Test")
  54. self.dps[DOORBELL_DPS] = "a25vY2sga25vY2s="
  55. image = await self.subject.async_camera_image()
  56. self.assertEqual(image, b"knock knock")
  57. async def test_turn_off(self):
  58. with self.assertRaises(NotImplementedError):
  59. await self.subject.async_turn_off()
  60. async def test_turn_on(self):
  61. with self.assertRaises(NotImplementedError):
  62. await self.subject.async_turn_on()