Skip to content

Commit

Permalink
Updated code for tests/users/test_dao.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aakankshaagr committed May 25, 2021
1 parent 83c64db commit c012786
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tests/users/test_dao.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
import unittest
from werkzeug.security import check_password_hash

from http import HTTPStatus
from app import messages
from app.api.email_utils import generate_confirmation_token
from app.api.dao.user import UserDAO
Expand Down Expand Up @@ -66,7 +66,8 @@ def test_dao_confirm_registration_good_token(self):
self.assertTrue(user.is_email_verified)
self.assertIsNotNone(user.email_verification_date)
self.assertEqual(
(messages.ACCOUNT_ALREADY_CONFIRMED_AND_THANKS, 200), actual_result
(messages.ACCOUNT_ALREADY_CONFIRMED_AND_THANKS, HTTPStatus.OK),
actual_result,
)

def test_dao_confirm_registration_bad_token(self):
Expand Down Expand Up @@ -96,7 +97,8 @@ def test_dao_confirm_registration_bad_token(self):
self.assertFalse(user.is_email_verified)
self.assertIsNone(user.email_verification_date)
self.assertEqual(
(messages.EMAIL_EXPIRED_OR_TOKEN_IS_INVALID, 400), actual_result
(messages.EMAIL_EXPIRED_OR_TOKEN_IS_INVALID, HTTPStatus.BAD_REQUEST),
actual_result,
)

def test_dao_confirm_registration_of_already_verified_user(self):
Expand Down Expand Up @@ -124,7 +126,9 @@ def test_dao_confirm_registration_of_already_verified_user(self):
actual_result = dao.confirm_registration(good_token)

self.assertTrue(user.is_email_verified)
self.assertEqual((messages.ACCOUNT_ALREADY_CONFIRMED, 200), actual_result)
self.assertEqual(
(messages.ACCOUNT_ALREADY_CONFIRMED, HTTPStatus.OK), actual_result
)

def test_dao_delete_only_user_admin(self):
dao = UserDAO()
Expand All @@ -140,7 +144,9 @@ def test_dao_delete_only_user_admin(self):
self.assertTrue(after_delete_user.is_admin)
self.assertIsNotNone(after_delete_user)
self.assertEqual(1, after_delete_user.id)
self.assertEqual((messages.USER_CANT_DELETE, 400), dao_result)
self.assertEqual(
(messages.USER_CANT_DELETE, HTTPStatus.BAD_REQUEST), dao_result
)

def test_get_achievements(self):
dao = UserDAO()
Expand Down

0 comments on commit c012786

Please sign in to comment.