From 393e6f2384c46eb61c2bd9bf174b91afacf84ae4 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Sun, 22 Oct 2023 02:29:57 +0100 Subject: [PATCH] indy student is forbidden --- codeforlife/user/tests/views/test_school.py | 35 +++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/codeforlife/user/tests/views/test_school.py b/codeforlife/user/tests/views/test_school.py index 67665edc..fbef7d26 100644 --- a/codeforlife/user/tests/views/test_school.py +++ b/codeforlife/user/tests/views/test_school.py @@ -71,6 +71,12 @@ def _login_student(self): password="Password1", ) + def _login_indy_student(self): + return self.login_indy_student( + email="indianajones@codeforlife.com", + password="Password1", + ) + """ Retrieve naming convention: test_retrieve__{user_type}__{same_school} @@ -78,6 +84,7 @@ def _login_student(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. same_school: A flag for if the school is the same school that the user is in. Options: @@ -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. @@ -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( @@ -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.