diff options
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r-- | yaksh/test_views.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 31066d1..58b7506 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -614,10 +614,7 @@ class TestMonitor(TestCase): self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, "yaksh/monitor.html") - self.assertEqual(response.context['msg'], "Quiz Results") self.assertEqual(response.context['papers'][0], self.answerpaper) - self.assertEqual(response.context['latest_attempts'][0], - self.answerpaper) def test_get_quiz_user_data(self): """ @@ -4955,6 +4952,14 @@ class TestDownloadCsv(TestCase): total_marks=1.0, fixed_question_order=str(self.question.id) ) self.question_paper.fixed_questions.add(self.question) + self.learning_unit = LearningUnit.objects.create( + order=1, type="quiz", quiz=self.quiz) + self.learning_module = LearningModule.objects.create( + order=1, name="download module", description="download module", + check_prerequisite=False, creator=self.user) + self.learning_module.learning_unit.add(self.learning_unit.id) + self.course.learning_module.add(self.learning_module) + # student answerpaper user_answer = "def add(a, b)\n\treturn a+b" @@ -5056,7 +5061,9 @@ class TestDownloadCsv(TestCase): kwargs={'course_id': self.course.id}), follow=True ) - file_name = "{0}.csv".format(self.course.name.lower()) + file_name = "{0}.csv".format( + self.course.name.replace(" ", "_").lower() + ) self.assertEqual(response.status_code, 200) self.assertEqual(response.get('Content-Disposition'), 'attachment; filename="{0}"'.format(file_name)) @@ -5089,15 +5096,16 @@ class TestDownloadCsv(TestCase): username=self.user.username, password=self.user_plaintext_pass ) - response = self.client.get( + response = self.client.post( reverse('yaksh:download_quiz_csv', kwargs={"course_id": self.course.id, "quiz_id": self.quiz.id}), + data={"attempt_number": 1}, follow=True ) - file_name = "{0}-{1}-attempt{2}.csv".format( - self.course.name.replace('.', ''), - self.quiz.description.replace('.', ''), 1 + file_name = "{0}-{1}-attempt-{2}.csv".format( + self.course.name.replace(' ', '_'), + self.quiz.description.replace(' ', '_'), 1 ) self.assertEqual(response.status_code, 200) self.assertEqual(response.get('Content-Disposition'), @@ -5660,11 +5668,9 @@ class TestShowStatistics(TestCase): self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'yaksh/statistics_question.html') self.assertIn(self.question, list(question_stats.keys())) - self.assertSequenceEqual( - list(question_stats.values())[0]['answered'], [1, 1] - ) - self.assertEqual(response.context['attempts'][0], 1) - self.assertEqual(response.context['total'], 1) + q_data = list(question_stats.values())[0] + self.assertSequenceEqual(q_data[0:2], [1, 1]) + self.assertEqual(100, q_data[2]) class TestQuestionPaper(TestCase): |