Merge pull request #338 from fronzbot/fix-auth-tests

Fix broken test and missing try/except
This commit is contained in:
Kevin Fronczak
2020-07-19 21:24:50 -04:00
committed by GitHub
2 changed files with 10 additions and 3 deletions
+9 -2
View File
@@ -174,11 +174,18 @@ class Auth:
"Connection error. Endpoint %s possibly down or throttled.", url,
)
except BlinkBadResponse:
code = None
reason = None
try:
code = response.status_code
reason = response.reason
except AttributeError:
pass
_LOGGER.error(
"Expected json response from %s, but received: %s: %s",
url,
response.status_code,
response.reason,
code,
reason,
)
except UnauthorizedError:
try:
+1 -1
View File
@@ -230,7 +230,7 @@ class TestAuth(unittest.TestCase):
@mock.patch("blinkpy.auth.Auth.refresh_token")
def test_query_retry_failed(self, mock_refresh, mock_validate):
"""Check handling of failed retry request."""
self.auth.seession = MockSession()
self.auth.session = MockSession()
mock_validate.side_effect = [UnauthorizedError, BlinkBadResponse]
mock_refresh.return_value = True
self.assertEqual(self.auth.query(url="http://example.com"), None)