Handle Timeout exceptions in system_health (#50017)
parent
378cee01b4
commit
9b89acea97
|
@ -216,6 +216,8 @@ async def async_check_can_reach_url(
|
|||
return "ok"
|
||||
except aiohttp.ClientError:
|
||||
data = {"type": "failed", "error": "unreachable"}
|
||||
if more_info is not None:
|
||||
data["more_info"] = more_info
|
||||
return data
|
||||
except asyncio.TimeoutError:
|
||||
data = {"type": "failed", "error": "timeout"}
|
||||
if more_info is not None:
|
||||
data["more_info"] = more_info
|
||||
return data
|
||||
|
|
|
@ -113,6 +113,7 @@ async def test_platform_loading(hass, hass_ws_client, aioclient_mock):
|
|||
"""Test registering via platform."""
|
||||
aioclient_mock.get("http://example.com/status", text="")
|
||||
aioclient_mock.get("http://example.com/status_fail", exc=ClientError)
|
||||
aioclient_mock.get("http://example.com/timeout", exc=asyncio.TimeoutError)
|
||||
hass.config.components.add("fake_integration")
|
||||
mock_platform(
|
||||
hass,
|
||||
|
@ -130,6 +131,11 @@ async def test_platform_loading(hass, hass_ws_client, aioclient_mock):
|
|||
"http://example.com/status_fail",
|
||||
more_info="http://more-info-url.com",
|
||||
),
|
||||
"server_timeout": system_health.async_check_can_reach_url(
|
||||
hass,
|
||||
"http://example.com/timeout",
|
||||
more_info="http://more-info-url.com",
|
||||
),
|
||||
"async_crash": AsyncMock(side_effect=ValueError)(),
|
||||
}
|
||||
),
|
||||
|
@ -150,6 +156,11 @@ async def test_platform_loading(hass, hass_ws_client, aioclient_mock):
|
|||
"error": "unreachable",
|
||||
"more_info": "http://more-info-url.com",
|
||||
},
|
||||
"server_timeout": {
|
||||
"type": "failed",
|
||||
"error": "timeout",
|
||||
"more_info": "http://more-info-url.com",
|
||||
},
|
||||
"async_crash": {
|
||||
"type": "failed",
|
||||
"error": "unknown",
|
||||
|
|
Loading…
Reference in New Issue