Skip to content

Commit

Permalink
tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jan 16, 2024
1 parent f235103 commit 16f57ce
Showing 1 changed file with 42 additions and 41 deletions.
83 changes: 42 additions & 41 deletions codeforlife/user/tests/permissions/test_in_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
"""
Expand All @@ -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.
"""
Expand All @@ -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.
Expand Down Expand Up @@ -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,
},
)

0 comments on commit 16f57ce

Please sign in to comment.