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

View File

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