Skip to content

Commit

Permalink
test actions
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Apr 19, 2024
1 parent 3ffbf13 commit bc5d98d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions codeforlife/user/views/klass_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
class TestClassViewSet(ModelViewSetTestCase[RequestUser, Class]):
basename = "class"
model_view_set_class = ClassViewSet
fixtures = ["school_1"]

def setUp(self):
self.admin_school_teacher_user = AdminSchoolTeacherUser.objects.get(
email="[email protected]"
)

# test: get permissions

Expand Down Expand Up @@ -81,3 +87,22 @@ def test_get_queryset__teacher__non_admin(self):
values=user.teacher.classes,
request=self.client.request_factory.get(user=user),
)

# test: actions

def test_retrieve(self):
"""Can successfully retrieve a class."""
user = StudentUser.objects.first()
assert user

self.client.login_as(user, password="Password1")
self.client.retrieve(model=user.student.class_field)

def test_list(self):
"""Can successfully list classes."""
user = self.admin_school_teacher_user
# TODO: assert user has classes in new schema.
assert user.teacher.classes.count() >= 2

self.client.login_as(user)
self.client.list(models=user.teacher.classes.all())

0 comments on commit bc5d98d

Please sign in to comment.