Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pvizeli committed Feb 26, 2020
1 parent 23da657 commit 67097e4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mock==4.0.1
nose==1.3.7
coverage==5.0.3
black==19.10b0
flake8==3.7.9
pylint==2.4.4
pylint==2.4.4
pytest==5.3.5
36 changes: 18 additions & 18 deletions tests/tests.py → tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,17 @@ def setUp(self):
client_secret=self.client_secret,
)

@patch("warrant.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("warrant.Cognito.verify_token", _mock_verify_tokens)
@patch("pycognito.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("pycognito.Cognito.verify_token", _mock_verify_tokens)
def test_authenticate(self):

self.user.authenticate(self.password)
self.assertNotEqual(self.user.access_token, None)
self.assertNotEqual(self.user.id_token, None)
self.assertNotEqual(self.user.refresh_token, None)

@patch("warrant.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("warrant.Cognito.verify_token", _mock_verify_tokens)
@patch("pycognito.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("pycognito.Cognito.verify_token", _mock_verify_tokens)
def test_verify_token(self):
self.user.authenticate(self.password)
bad_access_token = "{}wrong".format(self.user.access_token)
Expand All @@ -123,7 +123,7 @@ def test_verify_token(self):
# self.assertEqual(self.user.refresh_token,None)
# self.assertEqual(self.user.access_token,None)

@patch("warrant.Cognito", autospec=True)
@patch("pycognito.Cognito", autospec=True)
def test_register(self, cognito_user):
u = cognito_user(self.cognito_user_pool_id, self.app_id, username=self.username)
base_attr = dict(
Expand All @@ -141,9 +141,9 @@ def test_register(self, cognito_user):

self.assertEqual(res, base_attr)

@patch("warrant.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("warrant.Cognito.verify_token", _mock_verify_tokens)
@patch("warrant.Cognito._add_secret_hash", return_value=None)
@patch("pycognito.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("pycognito.Cognito.verify_token", _mock_verify_tokens)
@patch("pycognito.Cognito._add_secret_hash", return_value=None)
def test_renew_tokens(self, _):

stub = Stubber(self.user.client)
Expand All @@ -163,7 +163,7 @@ def test_renew_tokens(self, _):
},
expected_params={
"ClientId": self.app_id,
"AuthFlow": "REFRESH_TOKEN",
"AuthFlow": "REFRESH_TOKEN_AUTH",
"AuthParameters": {"REFRESH_TOKEN": "dummy_token"},
},
)
Expand All @@ -173,7 +173,7 @@ def test_renew_tokens(self, _):
self.user.renew_access_token()
stub.assert_no_pending_responses()

@patch("warrant.Cognito", autospec=True)
@patch("pycognito.Cognito", autospec=True)
def test_update_profile(self, cognito_user):
u = cognito_user(self.cognito_user_pool_id, self.app_id, username=self.username)
u.authenticate(self.password)
Expand Down Expand Up @@ -211,21 +211,21 @@ def test_check_token(self):
)
self.assertFalse(self.user.check_token())

@patch("warrant.Cognito", autospec=True)
@patch("pycognito.Cognito", autospec=True)
def test_validate_verification(self, cognito_user):
u = cognito_user(self.cognito_user_pool_id, self.app_id, username=self.username)
u.validate_verification("4321")

@patch("warrant.Cognito", autospec=True)
@patch("pycognito.Cognito", autospec=True)
def test_confirm_forgot_password(self, cognito_user):
u = cognito_user(self.cognito_user_pool_id, self.app_id, username=self.username)
u.confirm_forgot_password("4553", "samplepassword")
with self.assertRaises(TypeError):
u.confirm_forgot_password(self.password)

@patch("warrant.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("warrant.Cognito.verify_token", _mock_verify_tokens)
@patch("warrant.Cognito.check_token", return_value=True)
@patch("pycognito.aws_srp.AWSSRP.authenticate_user", _mock_authenticate_user)
@patch("pycognito.Cognito.verify_token", _mock_verify_tokens)
@patch("pycognito.Cognito.check_token", return_value=True)
def test_change_password(self, _):
# u = cognito_user(self.cognito_user_pool_id, self.app_id,
# username=self.username)
Expand Down Expand Up @@ -259,7 +259,7 @@ def test_set_attributes(self):

#

@patch("warrant.Cognito.verify_token", _mock_verify_tokens)
@patch("pycognito.Cognito.verify_token", _mock_verify_tokens)
def test_admin_authenticate(self):

stub = Stubber(self.user.client)
Expand Down Expand Up @@ -318,8 +318,8 @@ def setUp(self):
def tearDown(self):
del self.aws

@patch("warrant.aws_srp.AWSSRP.get_auth_params", _mock_get_params)
@patch("warrant.aws_srp.AWSSRP.process_challenge", return_value={})
@patch("pycognito.aws_srp.AWSSRP.get_auth_params", _mock_get_params)
@patch("pycognito.aws_srp.AWSSRP.process_challenge", return_value={})
def test_authenticate_user(self, _):

stub = Stubber(self.aws.client)
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py

This file was deleted.

6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ deps =
[testenv:lint]
ignore_errors = True
commands =
flake8 pycognito tests
flake8 pycognito tests.py
pylint --rcfile pylintrc pycognito

[testenv:black]
commands =
black --target-version py36 --check pycognito tests setup.py
black --target-version py36 --check pycognito tests.py setup.py

[testenv:tests]
commands =
nosetests tests/
pytest tests.py

0 comments on commit 67097e4

Please sign in to comment.