Correct logging and add test case for sharkiq (#41863)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Andrew Marks 2020-11-09 02:33:09 -05:00 committed by GitHub
parent f499187835
commit 42cdbc7e1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View file

@ -74,7 +74,7 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator):
SharkIqNotAuthedError,
SharkIqAuthExpiringError,
) as err:
_LOGGER.exception("Bad auth state")
_LOGGER.debug("Bad auth state. Attempting re-auth", exc_info=err)
flow_context = {
"source": "reauth",
"unique_id": self._config_entry.unique_id,
@ -87,6 +87,7 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator):
]
if not matching_flows:
_LOGGER.debug("Re-initializing flows. Attempting re-auth")
self.hass.async_create_task(
self.hass.config_entries.flow.async_init(
DOMAIN,
@ -94,6 +95,8 @@ class SharkIqUpdateCoordinator(DataUpdateCoordinator):
data=self._config_entry.data,
)
)
else:
_LOGGER.debug("Matching flow found")
raise UpdateFailed(err) from err
except Exception as err: # pylint: disable=broad-except

View file

@ -4,7 +4,7 @@ import enum
from typing import Any, Iterable, List, Optional
import pytest
from sharkiqpy import AylaApi, SharkIqAuthError, SharkIqVacuum
from sharkiqpy import AylaApi, SharkIqAuthError, SharkIqNotAuthedError, SharkIqVacuum
from homeassistant.components.homeassistant import SERVICE_UPDATE_ENTITY
from homeassistant.components.sharkiq import DOMAIN
@ -217,6 +217,7 @@ async def test_locate(hass):
[
(None, True),
(SharkIqAuthError, False),
(SharkIqNotAuthedError, False),
(RuntimeError, False),
],
)