hass-core/tests/components/abode/test_camera.py
shred86 d36259f067
Add Abode tests ()
* Add tests for several devices

* Update coveragerc

* Code review changes and minor clean up

* More code review changes

* Update manifest and minor test updates

* Add test for locks and covers

* Add tests for switch on and off

* Add more complete test for alarms

* Fix for camera test

* Patch abodepy.mode for tests

* Add test for unknown alarm state and minor cleanup

* Update to make tests more robust

* More specific tests

* Update quality scale to silver

* Remove integration quality scale
2020-03-16 03:05:10 +01:00

40 lines
1.3 KiB
Python

"""Tests for the Abode camera device."""
from unittest.mock import patch
from homeassistant.components.abode.const import DOMAIN as ABODE_DOMAIN
from homeassistant.components.camera import DOMAIN as CAMERA_DOMAIN
from homeassistant.const import ATTR_ENTITY_ID, STATE_IDLE
from .common import setup_platform
async def test_entity_registry(hass):
"""Tests that the devices are registered in the entity registry."""
await setup_platform(hass, CAMERA_DOMAIN)
entity_registry = await hass.helpers.entity_registry.async_get_registry()
entry = entity_registry.async_get("camera.test_cam")
assert entry.unique_id == "d0a3a1c316891ceb00c20118aae2a133"
async def test_attributes(hass):
"""Test the camera attributes are correct."""
await setup_platform(hass, CAMERA_DOMAIN)
state = hass.states.get("camera.test_cam")
assert state.state == STATE_IDLE
async def test_capture_image(hass):
"""Test the camera capture image service."""
await setup_platform(hass, CAMERA_DOMAIN)
with patch("abodepy.AbodeCamera.capture") as mock_capture:
await hass.services.async_call(
ABODE_DOMAIN,
"capture_image",
{ATTR_ENTITY_ID: "camera.test_cam"},
blocking=True,
)
await hass.async_block_till_done()
mock_capture.assert_called_once()