Skip to content

Commit

Permalink
make is_admin optional
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jan 25, 2024
1 parent bae7acb commit 195f1d9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions codeforlife/tests/model_view_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,20 +424,23 @@ def login(self, **credentials):

return user

def login_teacher(self, is_admin: bool, **credentials):
def login_teacher(self, is_admin: t.Optional[bool] = None, **credentials):
# pylint: disable=line-too-long
"""Log in a user and assert they are a teacher.
Args:
is_admin: Whether or not the teacher is an admin.
is_admin: Whether or not the teacher is an admin. Set none if a teacher can be either or.
Returns:
The teacher-user.
"""
# pylint: enable=line-too-long

user = self.login(**credentials)
assert user.teacher
assert user.teacher.school
assert is_admin == user.teacher.is_admin
if is_admin is not None:
assert is_admin == user.teacher.is_admin
return user

def login_student(self, **credentials):
Expand Down

0 comments on commit 195f1d9

Please sign in to comment.