From 5409b03f915c4569ccb17974e6c09660fa32d8bf Mon Sep 17 00:00:00 2001 From: prathamesh Date: Wed, 25 Jun 2014 10:45:22 +0530 Subject: Added test for new model fields and new methods created in models. --- testapp/exam/tests.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'testapp/exam/tests.py') diff --git a/testapp/exam/tests.py b/testapp/exam/tests.py index b2ba36f..2cc208a 100644 --- a/testapp/exam/tests.py +++ b/testapp/exam/tests.py @@ -21,7 +21,8 @@ def setUpModule(): # create a quiz Quiz.objects.create(start_date='2014-06-16', duration=30, active=False, - description='demo quiz') + description='demo quiz', pass_criteria=40, + language='Python', prerequisite=None) def tearDownModule(): @@ -86,6 +87,9 @@ class QuizTestCases(unittest.TestCase): self.assertEqual(self.quiz.duration, 30) self.assertTrue(self.quiz.active is False) self.assertEqual(self.quiz.description, 'demo quiz') + self.assertEqual(self.quiz.language, 'Python') + self.assertEqual(self.quiz.pass_criteria, 40) + self.assertEqual(self.quiz.prerequisite, None) ############################################################################### @@ -98,7 +102,8 @@ class QuestionPaperTestCases(unittest.TestCase): # create question paper self.question_paper = QuestionPaper.objects.create(quiz=self.quiz, - total_marks=0.0) + total_marks=0.0, shuffle_questions=True) + # add fixed set of questions to the question paper self.question_paper.fixed_questions.add(self.questions[3], self.questions[5]) @@ -135,6 +140,7 @@ class QuestionPaperTestCases(unittest.TestCase): self.assertEqual(self.question_paper.quiz.description, 'demo quiz') self.assertEqual(list(self.question_paper.fixed_questions.all()), [self.questions[3], self.questions[5]]) + self.assertTrue(self.question_paper.shuffle_questions) def test_update_total_marks(self): """ Test update_total_marks() method of Question Paper""" @@ -257,9 +263,20 @@ class AnswerPaperTestCases(unittest.TestCase): answered_question = self.answerpaper.get_answered_str() self.assertEqual(answered_question, '1') - def test_get_marks_obtained(self): + def test_update_marks_obtained(self): """ Test get_marks_obtained() method of Answer Paper""" - self.assertEqual(self.answerpaper.get_marks_obtained(), 1.0) + self.answerpaper.update_marks_obtained() + self.assertEqual(self.answerpaper.marks_obtained, 1.0) + + def test_update_percent(self): + """ Test update_percent() method of Answerpaper""" + self.answerpaper.update_percent() + self.assertEqual(self.answerpaper.percent, 33.33) + + def test_update_result(self): + """ Test update_result() method of AnswerPaper""" + self.answerpaper.update_result() + self.assertEqual(self.answerpaper.result, "FAILED") def test_get_question_answer(self): """ Test get_question_answer() method of Answer Paper""" -- cgit From b61c62291424089478064af1fceb81c1ed4e5c54 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 26 Jun 2014 17:51:06 +0530 Subject: Made pass field as boolean field. And changed variables to lowercases --- testapp/exam/tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testapp/exam/tests.py') diff --git a/testapp/exam/tests.py b/testapp/exam/tests.py index 2cc208a..eb63ba4 100644 --- a/testapp/exam/tests.py +++ b/testapp/exam/tests.py @@ -276,7 +276,7 @@ class AnswerPaperTestCases(unittest.TestCase): def test_update_result(self): """ Test update_result() method of AnswerPaper""" self.answerpaper.update_result() - self.assertEqual(self.answerpaper.result, "FAILED") + self.assertFalse(self.answerpaper.result) def test_get_question_answer(self): """ Test get_question_answer() method of Answer Paper""" -- cgit From 3c82dd0faf2f1273cb590b360a9696a973b30720 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Fri, 27 Jun 2014 12:03:18 +0530 Subject: Made the minor change --- testapp/exam/tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'testapp/exam/tests.py') diff --git a/testapp/exam/tests.py b/testapp/exam/tests.py index eb63ba4..d76e4f8 100644 --- a/testapp/exam/tests.py +++ b/testapp/exam/tests.py @@ -273,10 +273,10 @@ class AnswerPaperTestCases(unittest.TestCase): self.answerpaper.update_percent() self.assertEqual(self.answerpaper.percent, 33.33) - def test_update_result(self): - """ Test update_result() method of AnswerPaper""" - self.answerpaper.update_result() - self.assertFalse(self.answerpaper.result) + def test_update_passed(self): + """ Test update_passed method of AnswerPaper""" + self.answerpaper.update_passed() + self.assertFalse(self.answerpaper.passed) def test_get_question_answer(self): """ Test get_question_answer() method of Answer Paper""" -- cgit