2020-02-23 21:54:35 +00:00
|
|
|
"""The camera tests for the august platform."""
|
|
|
|
|
2021-01-01 21:31:56 +00:00
|
|
|
from unittest.mock import patch
|
|
|
|
|
2020-02-23 21:54:35 +00:00
|
|
|
from homeassistant.const import STATE_IDLE
|
|
|
|
|
|
|
|
from tests.components.august.mocks import (
|
|
|
|
_create_august_with_devices,
|
|
|
|
_mock_doorbell_from_fixture,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-02-29 11:12:50 +00:00
|
|
|
async def test_create_doorbell(hass, aiohttp_client):
|
2020-02-23 21:54:35 +00:00
|
|
|
"""Test creation of a doorbell."""
|
|
|
|
doorbell_one = await _mock_doorbell_from_fixture(hass, "get_doorbell.json")
|
|
|
|
|
2020-04-30 20:29:50 +00:00
|
|
|
with patch.object(
|
2020-03-09 20:54:05 +00:00
|
|
|
doorbell_one, "async_get_doorbell_image", create=False, return_value="image"
|
2020-02-29 11:12:50 +00:00
|
|
|
):
|
|
|
|
await _create_august_with_devices(hass, [doorbell_one])
|
|
|
|
|
|
|
|
camera_k98gidt45gul_name_camera = hass.states.get(
|
|
|
|
"camera.k98gidt45gul_name_camera"
|
|
|
|
)
|
|
|
|
assert camera_k98gidt45gul_name_camera.state == STATE_IDLE
|
|
|
|
|
|
|
|
url = hass.states.get("camera.k98gidt45gul_name_camera").attributes[
|
|
|
|
"entity_picture"
|
|
|
|
]
|
|
|
|
|
|
|
|
client = await aiohttp_client(hass.http.app)
|
|
|
|
resp = await client.get(url)
|
|
|
|
assert resp.status == 200
|
|
|
|
body = await resp.text()
|
|
|
|
assert body == "image"
|