diff options
author | Prabhu Ramachandran | 2018-03-22 18:10:54 +0530 |
---|---|---|
committer | GitHub | 2018-03-22 18:10:54 +0530 |
commit | c49550b6793c0481fae08f04c794218513894cc4 (patch) | |
tree | 8a767d224ac6a1688cd3eb301b2ccac40413fc7e /yaksh/test_models.py | |
parent | 30be89eef46a248fe6f7ff26a923593ea8371fb1 (diff) | |
parent | 734b221a98745ccb6218f43923731323a265966a (diff) | |
download | online_test-c49550b6793c0481fae08f04c794218513894cc4.tar.gz online_test-c49550b6793c0481fae08f04c794218513894cc4.tar.bz2 online_test-c49550b6793c0481fae08f04c794218513894cc4.zip |
Merge branch 'master' into Grades
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r-- | yaksh/test_models.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 255d5db..41730c3 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])) |