-
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
11 changed files
with
102 additions
and
19 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
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 |
---|---|---|
|
@@ -32,6 +32,7 @@ def test_objects__create_user(self): | |
teacher_fields = {"is_admin": True} | ||
user_fields = { | ||
"first_name": "first_name", | ||
"last_name": "last_name", | ||
"email": "[email protected]", | ||
"password": "password", | ||
} | ||
|
@@ -42,6 +43,7 @@ def test_objects__create_user(self): | |
) | ||
|
||
assert user.first_name == user_fields["first_name"] | ||
assert user.last_name == user_fields["last_name"] | ||
assert user.email == user_fields["email"] | ||
assert user.password != user_fields["password"] | ||
assert user.check_password(user_fields["password"]) | ||
|
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 |
---|---|---|
|
@@ -40,6 +40,7 @@ def test_constraints__profile(self): | |
User.objects.create_user( | ||
password="password", | ||
first_name="student_and_teacher", | ||
last_name="last_name", | ||
student=student, | ||
teacher=teacher, | ||
) | ||
|
@@ -55,6 +56,7 @@ def test_constraints__email__teacher(self): | |
User.objects.create_user( | ||
password="password", | ||
first_name="teacher", | ||
last_name="last_name", | ||
teacher=teacher, | ||
) | ||
|
||
|
@@ -86,6 +88,53 @@ def test_constraints__email__indy(self): | |
User.objects.create_user( | ||
password="password", | ||
first_name="first_name", | ||
last_name="last_name", | ||
) | ||
|
||
def test_constraints__last_name__teacher(self): | ||
""" | ||
Teachers must have a last name. | ||
""" | ||
|
||
teacher = Teacher.objects.create() | ||
|
||
with self.assert_raises_integrity_error(): | ||
User.objects.create_user( | ||
password="password", | ||
first_name="teacher", | ||
email="[email protected]", | ||
teacher=teacher, | ||
) | ||
|
||
def test_constraints__last_name__students(self): | ||
""" | ||
Students can't have a last name. | ||
""" | ||
|
||
student = Student.objects.create( | ||
auto_gen_password="password", | ||
klass=self.klass__AB123, | ||
school=self.school__1, | ||
) | ||
|
||
with self.assert_raises_integrity_error(): | ||
User.objects.create_user( | ||
password="password", | ||
first_name="student", | ||
last_name="last_name", | ||
student=student, | ||
) | ||
|
||
def test_constraints__last_name__indy(self): | ||
""" | ||
Independents must have a last name. | ||
""" | ||
|
||
with self.assert_raises_integrity_error(): | ||
User.objects.create_user( | ||
password="password", | ||
first_name="teacher", | ||
email="[email protected]", | ||
) | ||
|
||
def test_objects__create(self): | ||
|
@@ -103,13 +152,15 @@ def test_objects__create_user__teacher(self): | |
|
||
user_fields = { | ||
"first_name": "first_name", | ||
"last_name": "last_name", | ||
"email": "[email protected]", | ||
"password": "password", | ||
"teacher": Teacher.objects.create(), | ||
} | ||
|
||
user = User.objects.create_user(**user_fields) # type: ignore[arg-type] | ||
assert user.first_name == user_fields["first_name"] | ||
assert user.last_name == user_fields["last_name"] | ||
assert user.email == user_fields["email"] | ||
assert user.password != user_fields["password"] | ||
assert user.check_password(user_fields["password"]) | ||
|
@@ -143,12 +194,14 @@ def test_objects__create_user__indy(self): | |
|
||
user_fields = { | ||
"first_name": "first_name", | ||
"last_name": "last_name", | ||
"email": "[email protected]", | ||
"password": "password", | ||
} | ||
|
||
user = User.objects.create_user(**user_fields) | ||
assert user.first_name == user_fields["first_name"] | ||
assert user.last_name == user_fields["last_name"] | ||
assert user.email == user_fields["email"] | ||
assert user.password != user_fields["password"] | ||
assert user.check_password(user_fields["password"]) | ||
|
@@ -160,15 +213,17 @@ def test_objects__create_superuser__teacher(self): | |
|
||
user_fields = { | ||
"first_name": "first_name", | ||
"last_name": "last_name", | ||
"email": "[email protected]", | ||
"password": "password", | ||
"teacher": Teacher.objects.create(), | ||
} | ||
|
||
user = User.objects.create_superuser( | ||
**user_fields | ||
) # type: ignore[arg-type] | ||
**user_fields # type: ignore[arg-type] | ||
) | ||
assert user.first_name == user_fields["first_name"] | ||
assert user.last_name == user_fields["last_name"] | ||
assert user.email == user_fields["email"] | ||
assert user.password != user_fields["password"] | ||
assert user.check_password(user_fields["password"]) | ||
|
@@ -192,8 +247,8 @@ def test_objects__create_superuser__student(self): | |
} | ||
|
||
user = User.objects.create_superuser( | ||
**user_fields | ||
) # type: ignore[arg-type] | ||
**user_fields # type: ignore[arg-type] | ||
) | ||
assert user.first_name == user_fields["first_name"] | ||
assert user.password != user_fields["password"] | ||
assert user.check_password(user_fields["password"]) | ||
|
@@ -208,12 +263,14 @@ def test_objects__create_superuser__indy(self): | |
|
||
user_fields = { | ||
"first_name": "first_name", | ||
"last_name": "last_name", | ||
"email": "[email protected]", | ||
"password": "password", | ||
} | ||
|
||
user = User.objects.create_superuser(**user_fields) | ||
assert user.first_name == user_fields["first_name"] | ||
assert user.last_name == user_fields["last_name"] | ||
assert user.email == user_fields["email"] | ||
assert user.password != user_fields["password"] | ||
assert user.check_password(user_fields["password"]) | ||
|
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