mirror of
https://github.com/home-assistant/core.git
synced 2025-11-15 22:10:09 +00:00
Add support for attribute caching to the camera platform (#106256)
This commit is contained in:
@@ -58,10 +58,7 @@ async def mock_stream_source_fixture():
|
||||
with patch(
|
||||
"homeassistant.components.camera.Camera.stream_source",
|
||||
return_value=STREAM_SOURCE,
|
||||
) as mock_stream_source, patch(
|
||||
"homeassistant.components.camera.Camera.supported_features",
|
||||
return_value=camera.CameraEntityFeature.STREAM,
|
||||
):
|
||||
) as mock_stream_source:
|
||||
yield mock_stream_source
|
||||
|
||||
|
||||
@@ -71,10 +68,7 @@ async def mock_hls_stream_source_fixture():
|
||||
with patch(
|
||||
"homeassistant.components.camera.Camera.stream_source",
|
||||
return_value=HLS_STREAM_SOURCE,
|
||||
) as mock_hls_stream_source, patch(
|
||||
"homeassistant.components.camera.Camera.supported_features",
|
||||
return_value=camera.CameraEntityFeature.STREAM,
|
||||
):
|
||||
) as mock_hls_stream_source:
|
||||
yield mock_hls_stream_source
|
||||
|
||||
|
||||
@@ -934,19 +928,15 @@ async def test_use_stream_for_stills(
|
||||
return_value=True,
|
||||
):
|
||||
# First test when the integration does not support stream should fail
|
||||
resp = await client.get("/api/camera_proxy/camera.demo_camera")
|
||||
resp = await client.get("/api/camera_proxy/camera.demo_camera_without_stream")
|
||||
await hass.async_block_till_done()
|
||||
mock_stream_source.assert_not_called()
|
||||
assert resp.status == HTTPStatus.INTERNAL_SERVER_ERROR
|
||||
# Test when the integration does not provide a stream_source should fail
|
||||
with patch(
|
||||
"homeassistant.components.demo.camera.DemoCamera.supported_features",
|
||||
return_value=camera.CameraEntityFeature.STREAM,
|
||||
):
|
||||
resp = await client.get("/api/camera_proxy/camera.demo_camera")
|
||||
await hass.async_block_till_done()
|
||||
mock_stream_source.assert_called_once()
|
||||
assert resp.status == HTTPStatus.INTERNAL_SERVER_ERROR
|
||||
resp = await client.get("/api/camera_proxy/camera.demo_camera")
|
||||
await hass.async_block_till_done()
|
||||
mock_stream_source.assert_called_once()
|
||||
assert resp.status == HTTPStatus.INTERNAL_SERVER_ERROR
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.demo.camera.DemoCamera.stream_source",
|
||||
@@ -954,9 +944,6 @@ async def test_use_stream_for_stills(
|
||||
) as mock_stream_source, patch(
|
||||
"homeassistant.components.camera.create_stream"
|
||||
) as mock_create_stream, patch(
|
||||
"homeassistant.components.demo.camera.DemoCamera.supported_features",
|
||||
return_value=camera.CameraEntityFeature.STREAM,
|
||||
), patch(
|
||||
"homeassistant.components.demo.camera.DemoCamera.use_stream_for_stills",
|
||||
return_value=True,
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user