summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2017-10-05 10:21:14 +0530
committeradityacp2017-10-05 10:21:14 +0530
commit9f4cf9a4e3f51855f31028fbe68bcb992ce29791 (patch)
tree7497dc974dfc38a8ecc64671d68bd73a4e122f8e
parentdbacd863cfe3294a1f10f326710c65cfb591c6b2 (diff)
downloadonline_test-9f4cf9a4e3f51855f31028fbe68bcb992ce29791.tar.gz
online_test-9f4cf9a4e3f51855f31028fbe68bcb992ce29791.tar.bz2
online_test-9f4cf9a4e3f51855f31028fbe68bcb992ce29791.zip
Add test to fetch latest answer from answerpaper
-rw-r--r--yaksh/test_models.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index bc7f114..fd31ca2 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -547,6 +547,12 @@ class AnswerPaperTestCases(unittest.TestCase):
self.answerpaper.answers.add(self.answer_right)
self.answerpaper.answers.add(self.answer_wrong)
+ self.answer1 = Answer.objects.create(
+ question=self.question1,
+ answer="answer1", correct=False, error=json.dumps([])
+ )
+ self.answerpaper.answers.add(self.answer1)
+
self.question1.language = 'python'
self.question1.test_case_type = 'standardtestcase'
self.question1.summary = "Question1"
@@ -834,17 +840,22 @@ class AnswerPaperTestCases(unittest.TestCase):
def test_get_previous_answers(self):
answers = self.answerpaper.get_previous_answers(self.questions[0])
- self.assertEqual(answers.count(), 1)
+ self.assertEqual(answers.count(), 2)
self.assertTrue(answers[0], self.answer_right)
answers = self.answerpaper.get_previous_answers(self.questions[1])
self.assertEqual(answers.count(), 1)
self.assertTrue(answers[0], self.answer_wrong)
- def test_set_marks (self):
+ def test_set_marks(self):
self.answer_wrong.set_marks(0.5)
self.assertEqual(self.answer_wrong.marks, 0.5)
self.answer_wrong.set_marks(10.0)
- self.assertEqual(self.answer_wrong.marks,1.0)
+ self.assertEqual(self.answer_wrong.marks, 1.0)
+
+ def test_get_latest_answer(self):
+ latest_answer = self.answerpaper.get_latest_answer(self.question1.id)
+ self.assertEqual(latest_answer.id, self.answer1.id)
+ self.assertEqual(latest_answer.answer, "answer1")
###############################################################################