Skip to content

Commit

Permalink
indy student is forbidden
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Oct 22, 2023
1 parent 1a89c87 commit 393e6f2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions codeforlife/user/tests/views/test_school.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,20 @@ def _login_student(self):
password="Password1",
)

def _login_indy_student(self):
return self.login_indy_student(
email="[email protected]",
password="Password1",
)

"""
Retrieve naming convention:
test_retrieve__{user_type}__{same_school}
user_type: The type of user that is making the request. Options:
- teacher: A teacher.
- student: A school student.
- indy_student: A non-school student.
same_school: A flag for if the school is the same school that the user
is in. Options:
Expand All @@ -97,6 +104,21 @@ def _retrieve_school(
status_code_assertion,
)

def test_retrieve__indy_student(self):
"""
Independent student can not retrieve any school.
"""

self._login_indy_student()

school = School.objects.first()
assert school

self._retrieve_school(
school,
status_code_assertion=status.HTTP_403_FORBIDDEN,
)

def test_retrieve__teacher__same_school(self):
"""
Teacher can retrieve the same school they are in.
Expand Down Expand Up @@ -154,6 +176,7 @@ def test_retrieve__student__not_same_school(self):
user_type: The type of user that is making the request. Options:
- teacher: A teacher.
- student: A school student.
- indy_student: A non-school student.
"""

def _list_schools(
Expand All @@ -168,6 +191,18 @@ def _list_schools(
status_code_assertion,
)

def test_list__indy_student(self):
"""
Independent student can not list any schools.
"""

self._login_indy_student()

self._list_schools(
[],
status_code_assertion=status.HTTP_403_FORBIDDEN,
)

def test_list__teacher(self):
"""
Teacher can list only the school they are in.
Expand Down

0 comments on commit 393e6f2

Please sign in to comment.