-
Notifications
You must be signed in to change notification settings - Fork 24
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
5 changed files
with
54 additions
and
6 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 |
---|---|---|
|
@@ -21,9 +21,41 @@ class TestUser(ModelTestCase[User]): | |
def setUp(self): | ||
self.klass__AB123 = Class.objects.get(pk="AB123") | ||
self.school__1 = School.objects.get(pk=1) | ||
self.student__1 = Student.objects.get(pk=1) | ||
|
||
# TODO: test docstrings. | ||
|
||
def test_save__create(self): | ||
""" | ||
Cannot create a user calling save. | ||
""" | ||
|
||
with self.assert_raises_integrity_error(): | ||
User( | ||
first_name="first_name", | ||
last_name="last_name", | ||
email="[email protected]", | ||
password="password", | ||
).save() | ||
|
||
def test_save__first_name__student(self): | ||
""" | ||
Students must have a unique name per class. | ||
""" | ||
|
||
student = Student.objects.create( | ||
auto_gen_password="password", | ||
klass=self.student__1.klass, | ||
school=self.student__1.school, | ||
) | ||
|
||
with self.assert_raises_integrity_error(): | ||
User.objects.create_user( | ||
first_name=self.student__1.user.first_name, | ||
password="password", | ||
student=student, | ||
) | ||
|
||
def test_constraints__profile(self): | ||
""" | ||
Cannot be a student and a teacher. | ||
|