diff --git a/codeforlife/user/tests/permissions/test_in_class.py b/codeforlife/user/tests/permissions/test_in_class.py index 3ca65abd..e73d9f7e 100644 --- a/codeforlife/user/tests/permissions/test_in_class.py +++ b/codeforlife/user/tests/permissions/test_in_class.py @@ -60,7 +60,8 @@ def setUp(self): test_{class_id}__{user_type} class_id: The id of a class. Options: - - any_class: Any class. + - in_any_class: The user is in any class. + - not_in_any_class: The user is not in any class. - in_class: A specific class the user is in. - not_in_class: A specific class the user is not in. @@ -72,43 +73,43 @@ def setUp(self): - anon: An anonymous user. """ - def test_any_class__non_class_teacher(self): + def test_in_any_class__class_teacher(self): """ - Teacher without a class is not in any class. + Teacher with a class is in any class. """ - self.assert_not_has_permission( - self.non_class_teacher_request, + self.assert_has_permission( + self.class_teacher_request, init_kwargs={ "class_id": None, }, ) - def test_any_class__class_teacher(self): + def test_in_any_class__student(self): """ - Teacher with a class is in any class. + Student is in any class. """ self.assert_has_permission( - self.class_teacher_request, + self.student_request, init_kwargs={ "class_id": None, }, ) - def test_any_class__student(self): + def test_not_in_any_class__non_class_teacher(self): """ - Student is in any class. + Teacher without a class is not in any class. """ - self.assert_has_permission( - self.student_request, + self.assert_not_has_permission( + self.non_class_teacher_request, init_kwargs={ "class_id": None, }, ) - def test_any_class__indy(self): + def test_not_in_any_class__indy(self): """ Independent is not in any class. """ @@ -120,7 +121,7 @@ def test_any_class__indy(self): }, ) - def test_any_class__anon(self): + def test_not_in_any_class__anon(self): """ Anonymous user is not in any class. """ @@ -132,6 +133,33 @@ def test_any_class__anon(self): }, ) + def test_in_class__class_teacher(self): + """ + Teacher with a class is in a specific class. + """ + + klass = self.class_teacher__classes.first() + assert klass is not None + + self.assert_has_permission( + self.class_teacher_request, + init_kwargs={ + "class_id": klass.id, + }, + ) + + def test_in_class__student(self): + """ + Student is in a specific class. + """ + + self.assert_has_permission( + self.student_request, + init_kwargs={ + "class_id": self.student__class.id, + }, + ) + def test_not_in_class__non_class_teacher(self): """ Teacher without a class is not in a specific class. @@ -208,30 +236,3 @@ def test_not_in_class__anon(self): "class_id": klass.id, }, ) - - def test_in_class__class_teacher(self): - """ - Teacher with a class is in a specific class. - """ - - klass = self.class_teacher__classes.first() - assert klass is not None - - self.assert_has_permission( - self.class_teacher_request, - init_kwargs={ - "class_id": klass.id, - }, - ) - - def test_in_class__student(self): - """ - Student is in a specific class. - """ - - self.assert_has_permission( - self.student_request, - init_kwargs={ - "class_id": self.student__class.id, - }, - )