From 3597ee5fa814b0c7c737e72797d9e9911ca5e0dd Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Fri, 28 Apr 2017 15:01:18 +0530 Subject: - Fix bug that prevents addition of a prerequisite to foreignkey field - Fix test cases to ensure fails if prerequisite is not set --- yaksh/test_models.py | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'yaksh/test_models.py') diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 8e8865b..5a61c0f 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -914,6 +914,32 @@ class CourseTestCases(unittest.TestCase): self.questions[3] ) + self.template_quiz2 = Quiz.objects.create( + start_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, tzinfo=pytz.utc), + end_date_time=datetime(2199, 10, 9, 10, 8, 15, 0, tzinfo=pytz.utc), + duration=30, + active=True, + attempts_allowed=1, + time_between_attempts=0, + description='template quiz 2', + pass_criteria=0, + language='Python', + prerequisite=self.template_quiz, + course=self.template_course, + instructions="Demo Instructions" + ) + + self.template_question_paper2 = QuestionPaper.objects.create( + quiz=self.template_quiz2, + total_marks=0.0, + shuffle_questions=True + ) + + self.template_question_paper2.fixed_questions.add(self.questions[1], + self.questions[2], + self.questions[3] + ) + def test_create_duplicate_course(self): """ Test create_duplicate_course method of course """ # create a duplicate course @@ -986,6 +1012,57 @@ class CourseTestCases(unittest.TestCase): for q in cloned_qp.fixed_questions.all(): self.assertIn(q, self.template_question_paper.fixed_questions.all()) + # get second duplicate quiz associated with duplicate course + cloned_quiz = cloned_course.quiz_set.all()[1] + + self.assertEqual(cloned_quiz.start_date_time, + self.template_quiz2.start_date_time + ) + self.assertEqual(cloned_quiz.end_date_time, + self.template_quiz2.end_date_time + ) + self.assertEqual(cloned_quiz.duration, + self.template_quiz2.duration + ) + self.assertEqual(cloned_quiz.active, + self.template_quiz2.active + ) + self.assertEqual(cloned_quiz.attempts_allowed, + self.template_quiz2.attempts_allowed + ) + self.assertEqual(cloned_quiz.time_between_attempts, + self.template_quiz2.time_between_attempts + ) + self.assertEqual(cloned_quiz.description, + 'Copy Of template quiz 2' + ) + self.assertEqual(cloned_quiz.pass_criteria, + self.template_quiz2.pass_criteria + ) + self.assertEqual(cloned_quiz.language, + self.template_quiz2.language + ) + self.assertEqual(cloned_quiz.course, + cloned_course + ) + self.assertEqual(cloned_quiz.instructions, + self.template_quiz2.instructions + ) + + # Get second duplicate questionpaper associated with duplicate quiz + cloned_qp = cloned_quiz.questionpaper_set.all()[0] + + self.assertEqual(cloned_qp.quiz, cloned_quiz) + self.assertEqual(cloned_qp.total_marks, + self.template_question_paper2.total_marks + ) + self.assertEqual(cloned_qp.shuffle_questions, + self.template_question_paper2.shuffle_questions + ) + + for q in cloned_qp.fixed_questions.all(): + self.assertIn(q, self.template_question_paper2.fixed_questions.all()) + def test_is_creator(self): """ Test is_creator method of Course""" -- cgit