Cleanup some code
NOT FINISHED!
This commit is contained in:
@@ -3,10 +3,10 @@ from unittest import TestCase
|
||||
from unittest.mock import patch
|
||||
|
||||
from ActiveCollabAPI import AC_LOGIN_BASE_URL
|
||||
from ActiveCollabAPI.ACAuthenticator import ACAuthenticator
|
||||
from ActiveCollabAPI.AcAuthenticator import AcAuthenticator
|
||||
|
||||
|
||||
class TestACAuthenticator(TestCase):
|
||||
class TestAcAuthenticator(TestCase):
|
||||
|
||||
def mock_login_success(self):
|
||||
return {
|
||||
@@ -31,13 +31,13 @@ class TestACAuthenticator(TestCase):
|
||||
|
||||
|
||||
def test_login_success_gets_user_and_accounts_list(self):
|
||||
with patch("ActiveCollabAPI.ACAuthenticator.requests.post") as mock_post:
|
||||
with patch("ActiveCollabAPI.AcAuthenticator.requests.post") as mock_post:
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.mock_login_success()
|
||||
|
||||
email = "collab@example.com"
|
||||
password = "VeryS3cret!"
|
||||
authenticator = ACAuthenticator(AC_LOGIN_BASE_URL)
|
||||
authenticator = AcAuthenticator(AC_LOGIN_BASE_URL)
|
||||
response = authenticator.login(email, password)
|
||||
|
||||
self.assertEqual(200, response.status_code)
|
||||
@@ -57,13 +57,13 @@ class TestACAuthenticator(TestCase):
|
||||
}
|
||||
|
||||
def test_login_failed_not_ok(self):
|
||||
with patch("ActiveCollabAPI.ACAuthenticator.requests.post") as mock_post:
|
||||
with patch("ActiveCollabAPI.AcAuthenticator.requests.post") as mock_post:
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.mock_login_failed()
|
||||
|
||||
email = "collab@example.com"
|
||||
password = "VeryS3cret!"
|
||||
authenticator = ACAuthenticator(AC_LOGIN_BASE_URL)
|
||||
authenticator = AcAuthenticator(AC_LOGIN_BASE_URL)
|
||||
response = authenticator.login(email, password)
|
||||
|
||||
self.assertEqual(200, response.status_code)
|
||||
@@ -75,13 +75,13 @@ class TestACAuthenticator(TestCase):
|
||||
return {
|
||||
}
|
||||
def test_login_forbidden(self):
|
||||
with patch("ActiveCollabAPI.ACAuthenticator.requests.post") as mock_post:
|
||||
with patch("ActiveCollabAPI.AcAuthenticator.requests.post") as mock_post:
|
||||
mock_post.return_value.status_code = 401
|
||||
mock_post.return_value.json.return_value = self.mock_login_forbidden()
|
||||
|
||||
email = "collab@example.com"
|
||||
password = "VeryS3cret!"
|
||||
authenticator = ACAuthenticator(AC_LOGIN_BASE_URL)
|
||||
authenticator = AcAuthenticator(AC_LOGIN_BASE_URL)
|
||||
response = authenticator.login(email, password)
|
||||
|
||||
self.assertEqual(401, response.status_code)
|
||||
@@ -1,10 +1,10 @@
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch
|
||||
|
||||
from ActiveCollabAPI.ACTokenAuthenticator import ACTokenAuthenticator
|
||||
from ActiveCollabAPI.AcTokenAuthenticator import AcTokenAuthenticator
|
||||
|
||||
|
||||
class TestACTokenAuthenticator(TestCase):
|
||||
class TestAcTokenAuthenticator(TestCase):
|
||||
|
||||
def mock_token_success(self):
|
||||
return {
|
||||
@@ -13,11 +13,11 @@ class TestACTokenAuthenticator(TestCase):
|
||||
}
|
||||
|
||||
def test_issue_token_intent_success(self):
|
||||
with patch("ActiveCollabAPI.ACTokenAuthenticator.requests.post") as mock_post:
|
||||
with patch("ActiveCollabAPI.AcTokenAuthenticator.requests.post") as mock_post:
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.mock_token_success()
|
||||
|
||||
auth = ACTokenAuthenticator("http://mock")
|
||||
auth = AcTokenAuthenticator("http://mock")
|
||||
res = auth.issue_token_intent("this-is-the-token-intent-string")
|
||||
|
||||
self.assertEqual(200, res.status_code)
|
||||
@@ -31,11 +31,11 @@ class TestACTokenAuthenticator(TestCase):
|
||||
}
|
||||
|
||||
def test_issue_token_intent_not_ok(self):
|
||||
with patch("ActiveCollabAPI.ACTokenAuthenticator.requests.post") as mock_post:
|
||||
with patch("ActiveCollabAPI.AcTokenAuthenticator.requests.post") as mock_post:
|
||||
mock_post.return_value.status_code = 200
|
||||
mock_post.return_value.json.return_value = self.mock_token_not_ok()
|
||||
|
||||
auth = ACTokenAuthenticator("http://mock")
|
||||
auth = AcTokenAuthenticator("http://mock")
|
||||
res = auth.issue_token_intent("this-is-the-token-intent-string")
|
||||
|
||||
self.assertEqual(200, res.status_code)
|
||||
@@ -47,11 +47,11 @@ class TestACTokenAuthenticator(TestCase):
|
||||
}
|
||||
|
||||
def test_issue_token_intent_forbidden(self):
|
||||
with patch("ActiveCollabAPI.ACTokenAuthenticator.requests.post") as mock_post:
|
||||
with patch("ActiveCollabAPI.AcTokenAuthenticator.requests.post") as mock_post:
|
||||
mock_post.return_value.status_code = 401
|
||||
mock_post.return_value.json.return_value = self.mock_token_forbidden()
|
||||
|
||||
auth = ACTokenAuthenticator("http://mock")
|
||||
auth = AcTokenAuthenticator("http://mock")
|
||||
res = auth.issue_token_intent("this-is-the-token-intent-string")
|
||||
|
||||
self.assertEqual(401, res.status_code)
|
||||
Reference in New Issue
Block a user