Add an image placeholder for Nest WebRTC cameras (#58250)
This commit is contained in:
parent
6d30105c9f
commit
9c5a79c641
2 changed files with 52 additions and 6 deletions
|
@ -135,7 +135,7 @@ async def fire_alarm(hass, point_in_time):
|
|||
await hass.async_block_till_done()
|
||||
|
||||
|
||||
async def async_get_image(hass):
|
||||
async def async_get_image(hass, width=None, height=None):
|
||||
"""Get image from the camera, a wrapper around camera.async_get_image."""
|
||||
# Note: this patches ImageFrame to simulate decoding an image from a live
|
||||
# stream, however the test may not use it. Tests assert on the image
|
||||
|
@ -145,7 +145,9 @@ async def async_get_image(hass):
|
|||
autopatch=True,
|
||||
return_value=IMAGE_BYTES_FROM_STREAM,
|
||||
):
|
||||
return await camera.async_get_image(hass, "camera.my_camera")
|
||||
return await camera.async_get_image(
|
||||
hass, "camera.my_camera", width=width, height=height
|
||||
)
|
||||
|
||||
|
||||
async def test_no_devices(hass):
|
||||
|
@ -721,9 +723,11 @@ async def test_camera_web_rtc(hass, auth, hass_ws_client):
|
|||
assert msg["success"]
|
||||
assert msg["result"]["answer"] == "v=0\r\ns=-\r\n"
|
||||
|
||||
# Nest WebRTC cameras do not support a still image
|
||||
with pytest.raises(HomeAssistantError):
|
||||
await async_get_image(hass)
|
||||
# Nest WebRTC cameras return a placeholder
|
||||
content = await async_get_image(hass)
|
||||
assert content.content_type == "image/jpeg"
|
||||
content = await async_get_image(hass, width=1024, height=768)
|
||||
assert content.content_type == "image/jpeg"
|
||||
|
||||
|
||||
async def test_camera_web_rtc_unsupported(hass, auth, hass_ws_client):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue