Compare commits

..
Author SHA1 Message Date
Kevin FronczakandGitHub 0fc74c3f82 Merge pull request #319 from fronzbot/login-fix
Changed the way the new login method switch is handled
2020-06-29 13:06:01 -04:00
Kevin Fronczak 7b150eb1af Changed the way the new login method switch is handled 2020-06-29 17:01:46 +00:00
3 changed files with 18 additions and 2 deletions
+8 -1
View File
@@ -32,7 +32,7 @@ class Auth:
self.region_id = login_data.get("region_id", None)
self.client_id = login_data.get("client_id", None)
self.account_id = login_data.get("account_id", None)
self.login_url = LOGIN_ENDPOINT[login_method]
self.login_method = login_method
self.login_response = None
self.is_errored = False
self.no_prompt = no_prompt
@@ -55,6 +55,13 @@ class Auth:
return None
return {"Host": self.host, "TOKEN_AUTH": self.token}
@property
def login_url(self):
"""Return login url."""
if self.login_method not in LOGIN_ENDPOINT:
return LOGIN_ENDPOINT["v4"]
return LOGIN_ENDPOINT[self.login_method]
def create_session(self):
"""Create a session for blink communication."""
sess = Session()
+1 -1
View File
@@ -4,7 +4,7 @@ import os
MAJOR_VERSION = 0
MINOR_VERSION = 16
PATCH_VERSION = "0-rc9"
PATCH_VERSION = "0-rc10"
__version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}.{PATCH_VERSION}"
+9
View File
@@ -254,6 +254,15 @@ class TestAuth(unittest.TestCase):
mock_validate.side_effect = [UnauthorizedError, TokenRefreshFailed]
self.assertEqual(self.auth.query(url="http://example.com"), None)
def test_login_methods(self):
"""Test correct login url returned."""
auth = Auth()
self.assertEqual(auth.login_url, const.LOGIN_ENDPOINT["v4"])
auth.login_method = "v3"
self.assertEqual(auth.login_url, const.LOGIN_ENDPOINT["v3"])
auth.login_method = "foobar"
self.assertEqual(auth.login_url, const.LOGIN_ENDPOINT["v4"])
class MockSession:
"""Object to mock a session."""