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