1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Use async with to fetch HTTP streams in tests (#82788)

This commit is contained in:
uvjustin
2022-11-28 03:35:03 +08:00
committed by GitHub
parent 444ad52757
commit 31ad208500
2 changed files with 23 additions and 21 deletions

View File

@@ -503,15 +503,17 @@ async def test_camera_proxy_stream(hass, mock_camera, hass_client):
client = await hass_client()
response = await client.get("/api/camera_proxy_stream/camera.demo_camera")
assert response.status == HTTPStatus.OK
async with client.get("/api/camera_proxy_stream/camera.demo_camera") as response:
assert response.status == HTTPStatus.OK
with patch(
"homeassistant.components.demo.camera.DemoCamera.handle_async_mjpeg_stream",
return_value=None,
):
response = await client.get("/api/camera_proxy_stream/camera.demo_camera")
assert response.status == HTTPStatus.BAD_GATEWAY
async with await client.get(
"/api/camera_proxy_stream/camera.demo_camera"
) as response:
assert response.status == HTTPStatus.BAD_GATEWAY
async def test_websocket_web_rtc_offer(