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

Improve nest camera failure handling on removal (#63207)

This commit is contained in:
Allen Porter
2022-01-05 07:17:51 -08:00
committed by GitHub
parent 17b6f7ec88
commit d6c8f3965a
2 changed files with 36 additions and 2 deletions

View File

@@ -397,7 +397,7 @@ async def test_stream_response_already_expired(hass, auth):
async def test_camera_removed(hass, auth):
"""Test case where entities are removed and stream tokens expired."""
"""Test case where entities are removed and stream tokens revoked."""
subscriber = await async_setup_camera(
hass,
DEVICE_TRAITS,
@@ -433,6 +433,35 @@ async def test_camera_removed(hass, auth):
assert len(hass.states.async_all()) == 0
async def test_camera_remove_failure(hass, auth):
"""Test case where revoking the stream token fails on unload."""
await async_setup_camera(
hass,
DEVICE_TRAITS,
auth=auth,
)
assert len(hass.states.async_all()) == 1
cam = hass.states.get("camera.my_camera")
assert cam is not None
assert cam.state == STATE_STREAMING
# Start a stream, exercising cleanup on remove
auth.responses = [
make_stream_url_response(),
# Stop command will get a failure response
aiohttp.web.Response(status=HTTPStatus.INTERNAL_SERVER_ERROR),
]
stream_source = await camera.async_get_stream_source(hass, "camera.my_camera")
assert stream_source == "rtsp://some/url?auth=g.0.streamingToken"
# Unload should succeed even if an RPC fails
for config_entry in hass.config_entries.async_entries(DOMAIN):
await hass.config_entries.async_remove(config_entry.entry_id)
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 0
async def test_refresh_expired_stream_failure(hass, auth):
"""Tests a failure when refreshing the stream."""
now = utcnow()