-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from app.database.models.task_comment import TaskCommentModel | ||
from tests.base_test_case import BaseTestCase | ||
|
||
|
||
class TestAdminUserModel(BaseTestCase): | ||
def test_task_validations_comment(self): | ||
self.assertRaises( | ||
AssertionError, | ||
TaskCommentModel, | ||
user_id=1, | ||
task_id=1, | ||
relation_id=1, | ||
comment="" | ||
) | ||
|
||
def test_task_validations_comment_strip(self): | ||
comment = TaskCommentModel( | ||
user_id=1, | ||
task_id=1, | ||
relation_id=1, | ||
comment=" user ") | ||
self.assertEqual(comment.comment, "user") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,16 +7,16 @@ | |
|
||
from tests.test_data import test_admin_user | ||
|
||
|
||
# Testing User database model | ||
# | ||
# TODO tests: | ||
# - User insertion/deletion/update/read | ||
# - Check if first user is an admin | ||
|
||
|
||
class TestAdminUserModel(BaseTestCase): | ||
class TestUserModel(BaseTestCase): | ||
def test_is_first_user_admin(self): | ||
|
||
user = UserModel.query.filter_by(email=test_admin_user["email"]).first() | ||
self.assertTrue(user is not None) | ||
self.assertTrue(user.id is not None) | ||
|
@@ -31,7 +31,6 @@ def test_is_first_user_admin(self): | |
) | ||
|
||
def test_second_user_cannot_be_admin(self): | ||
|
||
user = UserModel( | ||
name="User1", | ||
email="[email protected]", | ||
|
@@ -55,6 +54,50 @@ def test_second_user_cannot_be_admin(self): | |
self.assertIsInstance(user.registration_date, float) | ||
self.assertFalse(user.is_email_verified) | ||
|
||
def test_user_validations_name(self): | ||
self.assertRaises( | ||
AssertionError, | ||
UserModel, | ||
name="User@$1", | ||
email="[email protected]", | ||
username="user", | ||
password="user1_password", | ||
terms_and_conditions_checked=True, | ||
) | ||
|
||
def test_user_validations_email(self): | ||
self.assertRaises( | ||
AssertionError, | ||
UserModel, | ||
name="User1", | ||
email="user1", | ||
username="user", | ||
password="user1_password", | ||
terms_and_conditions_checked=True, | ||
) | ||
|
||
def test_user_validations_username(self): | ||
self.assertRaises( | ||
AssertionError, | ||
UserModel, | ||
name="User", | ||
email="[email protected]", | ||
username="user_not$$_admin", | ||
password="user1_password", | ||
terms_and_conditions_checked=True, | ||
) | ||
|
||
def test_user_validations(self): | ||
self.assertRaises( | ||
AssertionError, | ||
UserModel, | ||
name="User", | ||
email="[email protected]", | ||
username="user_not_admin", | ||
password="user1_password", | ||
terms_and_conditions_checked=False, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |