summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authormahesh2018-02-07 15:58:54 +0530
committermaheshgudi2018-03-16 15:15:50 +0530
commit3fb6c4219c7c288fdf47ca300a1d859653c358b3 (patch)
treebaf860a4d47d7f53c2feec9d1a0a794bf2cd6185 /yaksh/test_models.py
parent537d0fc5c5884ab620e587ff977ed61a2a50504d (diff)
downloadonline_test-3fb6c4219c7c288fdf47ca300a1d859653c358b3.tar.gz
online_test-3fb6c4219c7c288fdf47ca300a1d859653c358b3.tar.bz2
online_test-3fb6c4219c7c288fdf47ca300a1d859653c358b3.zip
Add test cases for Arrange question type
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index a0ccd49..bebc929 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -1372,12 +1372,20 @@ class AnswerPaperTestCases(unittest.TestCase):
def test_get_question_answer(self):
""" Test get_question_answer() method of Answer Paper"""
+ questions = self.answerpaper.questions.all()
answered = self.answerpaper.get_question_answers()
- first_answer = list(answered.values())[0][0]
- first_answer_obj = first_answer['answer']
- self.assertEqual(first_answer_obj.answer, 'Demo answer')
- self.assertTrue(first_answer_obj.correct)
- self.assertEqual(len(answered), 2)
+ for question in questions:
+ answers_saved = Answer.objects.filter(question=question)
+ error_list = [json.loads(ans.error) for ans in answers_saved]
+ if answers_saved:
+ self.assertEqual(len(answered[question]), len(answers_saved))
+ ans_list = []
+ err_list = []
+ for val in answered[question]:
+ ans_list.append(val.get('answer'))
+ err_list.append(val.get('error_list'))
+ self.assertEqual(set(ans_list), set(answers_saved))
+ self.assertEqual(error_list, err_list)
def test_is_answer_correct(self):
self.assertTrue(self.answerpaper.is_answer_correct(self.questions[0]))