Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fc74c3f82 | ||
|
|
7b150eb1af |
+8
-1
@@ -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()
|
||||
|
||||
@@ -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}"
|
||||
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user