Skip to content

Commit

Permalink
test: test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharis278 committed Jul 15, 2024
1 parent eadc4cb commit 60b94d2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions edx_exams/apps/api/v1/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1800,20 +1800,15 @@ def test_auth_required(self):
# course staff has access
course_staff_user = UserFactory.create()
CourseStaffRole.objects.create(user=course_staff_user, course_id=self.course_id)
response = self.get_api(course_staff_user, self.course_id)
response = self.request_api('get', course_staff_user, self.course_id)
self.assertEqual(response.status_code, 200)

def test_get_allowances(self):
"""
Test that the endpoint returns allowances for the requested course
and only the requested course
"""
other_exam_in_course = ExamFactory.create(
course_id=self.exam.course_id,
)
another_course_exam = ExamFactory.create(
course_id='course-v1:edx+another+course',
)
other_exam_in_course = ExamFactory.create(course_id=self.exam.course_id)
StudentAllowanceFactory.create(
exam=self.exam,
user=self.user,
Expand All @@ -1823,7 +1818,7 @@ def test_get_allowances(self):
user=self.user,
)
StudentAllowanceFactory.create(
exam=another_course_exam,
exam=ExamFactory.create(course_id='course-v1:edx+another+course'),
user=self.user,
)

Expand All @@ -1848,3 +1843,11 @@ def test_get_allowances(self):
'username': self.user.username,
'extra_time_mins': 30,
})

def test_get_empty_response(self):
"""
Test that the endpoint returns an empty list if no allowances exist
"""
response = self.request_api('get', self.user, 'course-v1:edx+no+allowances')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.data, [])

0 comments on commit 60b94d2

Please sign in to comment.