diff options
author | prathamesh | 2014-06-21 16:01:34 +0530 |
---|---|---|
committer | prathamesh | 2014-06-21 16:01:34 +0530 |
commit | a31b44d170a26a51587d3c1c1080d5d90f1db356 (patch) | |
tree | b4166f0350cb702c035c8670acc842901fa43bb9 | |
parent | 75943b5561f2849ee4efc59c6ba4b8468caae88f (diff) | |
download | online_test-a31b44d170a26a51587d3c1c1080d5d90f1db356.tar.gz online_test-a31b44d170a26a51587d3c1c1080d5d90f1db356.tar.bz2 online_test-a31b44d170a26a51587d3c1c1080d5d90f1db356.zip |
Added assertion in test_get_random_questions, to check the order of questions.
-rw-r--r-- | testapp/exam/tests.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/testapp/exam/tests.py b/testapp/exam/tests.py index 29c22ac..2a5f1e7 100644 --- a/testapp/exam/tests.py +++ b/testapp/exam/tests.py @@ -142,18 +142,22 @@ class QuestionPaperTestCases(unittest.TestCase): def test_get_random_questions(self): """ Test get_random_questions() method of Question Paper""" - random_questions_set_1 = set(self.question_set_1. - get_random_questions()) - random_questions_set_2 = set(self.question_set_2. - get_random_questions()) + random_questions_set_1 = self.question_set_1.get_random_questions() + random_questions_set_2 = self.question_set_2.get_random_questions() # To check whether random questions are from random_question_set - boolean = set(self.question_set_1.questions.all()).\ - intersection(random_questions_set_1)\ - == random_questions_set_1 + questions_set_1 = set(self.question_set_1.questions.all()) + random_set_1 = set(random_questions_set_1) + random_set_2 = set(random_questions_set_2) + boolean = questions_set_1.intersection(random_set_1) == random_set_1 self.assertTrue(boolean) - self.assertEqual(len(random_questions_set_1), 2) - self.assertFalse(random_questions_set_1 == random_questions_set_2) + self.assertEqual(len(random_set_1), 2) + # To check that the questions are random. + # If incase not random then check that the order is diferent + try: + self.assertFalse(random_set_1 == random_set_2) + except AssertionError: + self.assertTrue(random_questions_set_1 != random_questions_set_2) def test_get_questions_for_answerpaper(self): """ Test get_questions_for_answerpaper() method of Question Paper""" |