From 1e5c8af8748602d90a52f51d45799274155f8cd9 Mon Sep 17 00:00:00 2001 From: adityacp Date: Mon, 25 Jan 2021 13:12:56 +0530 Subject: Fix views and models tests --- yaksh/test_views.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'yaksh/test_views.py') diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 31066d1..89d209e 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -4955,6 +4955,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 +5064,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 +5099,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'), -- cgit From 7f28b418b616823f542faea8311e881faf6286c2 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 26 Jan 2021 14:38:46 +0530 Subject: Refactor question statistics for a quiz --- yaksh/test_views.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'yaksh/test_views.py') diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 89d209e..8973d9f 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -5671,11 +5671,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): -- cgit From fa8020b9f39b4e75a0a5d8b26653cc61cb9ae981 Mon Sep 17 00:00:00 2001 From: adityacp Date: Wed, 27 Jan 2021 16:36:51 +0530 Subject: Refactor monitor for a quiz --- yaksh/test_views.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'yaksh/test_views.py') diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 8973d9f..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): """ -- cgit