Handle WebSocket client disconnect during prepare (#124173)
This commit is contained in:
parent
fc767ee562
commit
108a54a4a8
2 changed files with 27 additions and 2 deletions
|
@ -363,12 +363,12 @@ async def test_non_json_message(
|
|||
assert "bad=<object" in caplog.text
|
||||
|
||||
|
||||
async def test_prepare_fail(
|
||||
async def test_prepare_fail_timeout(
|
||||
hass: HomeAssistant,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test failing to prepare."""
|
||||
"""Test failing to prepare due to timeout."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.websocket_api.http.web.WebSocketResponse.prepare",
|
||||
|
@ -381,6 +381,24 @@ async def test_prepare_fail(
|
|||
assert "Timeout preparing request" in caplog.text
|
||||
|
||||
|
||||
async def test_prepare_fail_connection_reset(
|
||||
hass: HomeAssistant,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test failing to prepare due to connection reset."""
|
||||
with (
|
||||
patch(
|
||||
"homeassistant.components.websocket_api.http.web.WebSocketResponse.prepare",
|
||||
side_effect=(ConnectionResetError, web.WebSocketResponse.prepare),
|
||||
),
|
||||
pytest.raises(WSServerHandshakeError),
|
||||
):
|
||||
await hass_ws_client(hass)
|
||||
|
||||
assert "Connection reset by peer while preparing WebSocket" in caplog.text
|
||||
|
||||
|
||||
async def test_enable_coalesce(
|
||||
hass: HomeAssistant,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue