Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed May 23, 2024
1 parent 094e1fa commit 967becc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kolibri/core/exams/test/test_exam_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ def setUpTestData(cls):

def make_basic_exam(self):
sections = self.make_basic_sections(1)
total_questions = sum(section["question_count"] for section in sections)
return {
"title": "Exam",
"question_count": total_questions,
"active": True,
"collection": self.classroom.id,
"learners_see_fixed_order": False,
Expand Down Expand Up @@ -551,3 +549,13 @@ def test_exam_model_get_questions_v2_v1(self):

self.exam.save()
self.assertEqual(len(self.exam.get_questions()), 1)

def test_exam_question_count_calculation(self):
self.login_as_admin()
exam = self.make_basic_exam()
question_count = sum(len(source["questions"]) for source in exam["question_sources"])
response = self.post_new_exam(exam)
exam_id = response.data["id"]
self.assertEqual(response.status_code, 201)
exam_model_instance = models.Exam.objects.get(id=exam_id)
self.assertEqual(exam_model_instance.question_count, question_count)

0 comments on commit 967becc

Please sign in to comment.