summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2018-03-22 18:09:03 +0530
committerGitHub2018-03-22 18:09:03 +0530
commit734b221a98745ccb6218f43923731323a265966a (patch)
treeb9ad94f07ae3891295656203c169cb0b03b08d96 /yaksh/test_models.py
parent4b356aa2f6097cd0f46292218f31ded18b631e53 (diff)
parent09ab00808ba9ea288047662e5c7ee2a134f0ac41 (diff)
downloadonline_test-734b221a98745ccb6218f43923731323a265966a.tar.gz
online_test-734b221a98745ccb6218f43923731323a265966a.tar.bz2
online_test-734b221a98745ccb6218f43923731323a265966a.zip
Merge pull request #434 from maheshgudi/arrange_options
Arrange options 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 49bba00..e7a6fe5 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 = []
+ err = []
+ for val in answered[question]:
+ ans.append(val.get('answer'))
+ err.append(val.get('error_list'))
+ self.assertEqual(set(ans), set(answers_saved))
+ self.assertEqual(error_list, err)
def test_is_answer_correct(self):
self.assertTrue(self.answerpaper.is_answer_correct(self.questions[0]))