Support more errors to better do retries in UniFi (#44108)

This commit is contained in:
Robert Svensson 2020-12-10 21:25:50 +01:00 committed by GitHub
parent 6253054fd4
commit 9651d1bcfa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 5 deletions

View file

@ -295,6 +295,22 @@ async def test_get_controller_login_failed(hass):
await get_controller(hass, **CONTROLLER_DATA)
async def test_get_controller_controller_bad_gateway(hass):
"""Check that get_controller can handle controller being unavailable."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.BadGateway
), pytest.raises(CannotConnect):
await get_controller(hass, **CONTROLLER_DATA)
async def test_get_controller_controller_service_unavailable(hass):
"""Check that get_controller can handle controller being unavailable."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
"aiounifi.Controller.login", side_effect=aiounifi.ServiceUnavailable
), pytest.raises(CannotConnect):
await get_controller(hass, **CONTROLLER_DATA)
async def test_get_controller_controller_unavailable(hass):
"""Check that get_controller can handle controller being unavailable."""
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(