summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormahesh2018-02-08 16:30:49 +0530
committermaheshgudi2018-03-16 15:15:50 +0530
commitd4c79e599bfee207790632a71848d383fae7bd25 (patch)
tree268102796a7b4d58c847f1b925534f7181bae567
parent55dd1da1191dccbf66193ccd4d1a1a833bfe4513 (diff)
downloadonline_test-d4c79e599bfee207790632a71848d383fae7bd25.tar.gz
online_test-d4c79e599bfee207790632a71848d383fae7bd25.tar.bz2
online_test-d4c79e599bfee207790632a71848d383fae7bd25.zip
Improve test cases for arrange question type
-rw-r--r--yaksh/evaluator_tests/test_simple_question_types.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/yaksh/evaluator_tests/test_simple_question_types.py b/yaksh/evaluator_tests/test_simple_question_types.py
index c113cc8..1c62e79 100644
--- a/yaksh/evaluator_tests/test_simple_question_types.py
+++ b/yaksh/evaluator_tests/test_simple_question_types.py
@@ -1,6 +1,7 @@
import unittest
from datetime import datetime, timedelta
from django.utils import timezone
+from textwrap import dedent
import pytz
from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\
QuestionSet, AnswerPaper, Answer, Course, IntegerTestCase, FloatTestCase,\
@@ -667,16 +668,33 @@ class ArrangeQuestionTestCases(unittest.TestCase):
# Regrade with wrong answer
# Given
regrade_answer = Answer.objects.get(id=self.answer.id)
+
+ # Try regrade with wrong data structure
+ # When
+ regrade_answer.answer = 1
+ regrade_answer.save()
+ details = self.answerpaper.regrade(self.question1.id)
+ err_msg = dedent("""\
+ User: {0}; Quiz: {1}; Question: {2}.
+ {3} answer not a list.""".format(
+ self.user.username,
+ self.quiz.description,
+ self.question1.summary,
+ self.question1.type
+ ) )
+ self.assertFalse(details[0])
+ self.assertEqual(details[1], err_msg)
+
+
+ # Try regrade with incorrect answer
+ # When
regrade_answer.answer = [self.testcase_1_id,
self.testcase_3_id,
self.testcase_2_id,
]
regrade_answer.save()
-
- # When
- details = self.answerpaper.regrade(self.question1.id)
-
# Then
+ details = self.answerpaper.regrade(self.question1.id)
self.answer = self.answerpaper.answers.filter(question=self.question1
).last()
self.assertEqual(self.answer, regrade_answer)