summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authoradityacp2017-02-22 15:01:24 +0530
committeradityacp2017-03-10 15:41:07 +0530
commitb8d6116cd59f68888aca8f2acceecc9b85ebf7de (patch)
treee174a3e4a9c6927c15b01183cb95075d60eea963 /yaksh/test_models.py
parentc2ffb981b81410006a04b43997a2441a99dbff3d (diff)
downloadonline_test-b8d6116cd59f68888aca8f2acceecc9b85ebf7de.tar.gz
online_test-b8d6116cd59f68888aca8f2acceecc9b85ebf7de.tar.bz2
online_test-b8d6116cd59f68888aca8f2acceecc9b85ebf7de.zip
Change models and views test to get fixed questions
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index cd66aed..efd5fd3 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -1,7 +1,7 @@
import unittest
from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\
QuestionSet, AnswerPaper, Answer, Course, StandardTestCase,\
- StdIOBasedTestCase, FileUpload, McqTestCase
+ StdIOBasedTestCase, FileUpload, McqTestCase, FixedQuestions
import json
from datetime import datetime, timedelta
from django.utils import timezone
@@ -325,8 +325,10 @@ class QuestionPaperTestCases(unittest.TestCase):
)
# add fixed set of questions to the question paper
- self.question_paper.fixed_questions.add(self.questions[3],
- self.questions[5])
+ fixed_ques = FixedQuestions()
+ fixed_ques.add_fixed_questions(self.question_paper, self.questions[3])
+ fixed_ques.add_fixed_questions(self.question_paper, self.questions[5])
+
# create two QuestionSet for random questions
# QuestionSet 1
self.question_set_1 = QuestionSet.objects.create(marks=2,
@@ -374,8 +376,9 @@ class QuestionPaperTestCases(unittest.TestCase):
def test_questionpaper(self):
""" Test question paper"""
self.assertEqual(self.question_paper.quiz.description, 'demo quiz')
- self.assertSequenceEqual(self.question_paper.fixed_questions.all(),
- [self.questions[3], self.questions[5]])
+ fixed_ques = FixedQuestions()
+ ques = fixed_ques.get_fixed_questions(self.question_paper)
+ self.assertSequenceEqual(ques, [self.questions[3], self.questions[5]])
self.assertTrue(self.question_paper.shuffle_questions)
def test_update_total_marks(self):
@@ -415,7 +418,8 @@ class QuestionPaperTestCases(unittest.TestCase):
self.assertIsInstance(answerpaper, AnswerPaper)
paper_questions = answerpaper.questions.all()
self.assertEqual(len(paper_questions), 7)
- fixed_questions = set(self.question_paper.fixed_questions.all())
+ fixed_ques = FixedQuestions()
+ fixed_questions = set(fixed_ques.get_fixed_questions(self.question_paper))
self.assertTrue(fixed_questions.issubset(set(paper_questions)))
answerpaper.passed = True
answerpaper.save()
@@ -429,8 +433,8 @@ class QuestionPaperTestCases(unittest.TestCase):
self.question_paper.id
)
self.assertEqual(trial_paper.quiz, trial_quiz)
- self.assertEqual(trial_paper.fixed_questions.all(),
- self.question_paper.fixed_questions.all()
+ self.assertEqual(fixed_ques.get_fixed_questions(trial_paper),
+ fixed_ques.get_fixed_questions(self.question_paper)
)
self.assertEqual(trial_paper.random_questions.all(),
self.question_paper.random_questions.all()
@@ -442,10 +446,10 @@ class QuestionPaperTestCases(unittest.TestCase):
trial_quiz, self.questions_list
)
self.assertEqual(trial_paper.quiz, trial_quiz)
- self.assertEqual(self.questions_list,
- self.question_paper.fixed_questions
- .values_list("id", flat=True)
- )
+ fixed_q = FixedQuestions.objects.filter(
+ questionpaper=self.question_paper).values_list(
+ 'question_id', flat=True)
+ self.assertEqual(self.questions_list, fixed_q)
###############################################################################