summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2017-10-07 20:15:04 +0530
committeradityacp2017-10-07 20:15:04 +0530
commitf7a1535c60663cd99da62b59de939628502e953d (patch)
treec7c9625f871c4d559860165f2db0ed0fd1d52c8c
parent39ec0271244826b2693f01f6daaa99525404e15a (diff)
downloadonline_test-f7a1535c60663cd99da62b59de939628502e953d.tar.gz
online_test-f7a1535c60663cd99da62b59de939628502e953d.tar.bz2
online_test-f7a1535c60663cd99da62b59de939628502e953d.zip
Add test to get current question for AnswerPaper
-rw-r--r--yaksh/test_models.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 03af521..00506cd 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -525,6 +525,7 @@ class AnswerPaperTestCases(unittest.TestCase):
question_paper=self.question_paper,
user=self.user
)
+ self.question_paper.fixed_questions.add(*self.questions)
already_attempted = self.attempted_papers.count()
self.answerpaper.attempt_number = already_attempted + 1
self.answerpaper.save()
@@ -598,8 +599,8 @@ class AnswerPaperTestCases(unittest.TestCase):
quiz=self.quiz2, total_marks=3, shuffle_questions=True)
self.question_paper2.save()
summary_list = ['Q%d' % (i) for i in range(1, 21)]
- que_list = Question.objects.filter(summary__in=summary_list)
- self.question_paper2.fixed_questions.add(*que_list)
+ self.que_list = Question.objects.filter(summary__in=summary_list)
+ self.question_paper2.fixed_questions.add(*self.que_list)
# Create AnswerPaper for user1 and user2
self.user1_answerpaper = self.question_paper2.make_answerpaper(
@@ -609,6 +610,10 @@ class AnswerPaperTestCases(unittest.TestCase):
self.user2, self.ip, 1
)
+ self.user2_answerpaper2 = self.question_paper.make_answerpaper(
+ self.user2, self.ip, 1
+ )
+
def test_validate_and_regrade_mcc_correct_answer(self):
# Given
mcc_answer = [str(self.mcc_based_testcase.id)]
@@ -881,6 +886,11 @@ class AnswerPaperTestCases(unittest.TestCase):
ques_set_2 = self.user2_answerpaper.get_all_ordered_questions()
self.assertFalse(ques_set_1 == ques_set_2)
+ def test_validate_current_question(self):
+ self.user2_answerpaper2.questions_unanswered.remove(*self.questions)
+ self.assertEqual(self.user2_answerpaper2.current_question(),
+ self.question1)
+
###############################################################################
class CourseTestCases(unittest.TestCase):