diff options
author | Prabhu Ramachandran | 2015-07-31 12:49:57 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2015-07-31 12:49:57 +0530 |
commit | 0225aad1492600ed53504b0986fd13da24c28ae9 (patch) | |
tree | 06e1598081ed64fcc2b034a0cac263f7fe46e354 /testapp/exam/tests.py | |
parent | bbb991f8c6dbbcc6d12e93f3574ffcfbec2cb810 (diff) | |
parent | 3f0bb01600535b105c265e9da63814af06c0ab9d (diff) | |
download | online_test-0225aad1492600ed53504b0986fd13da24c28ae9.tar.gz online_test-0225aad1492600ed53504b0986fd13da24c28ae9.tar.bz2 online_test-0225aad1492600ed53504b0986fd13da24c28ae9.zip |
Merge pull request #51 from ankitjavalkar/add-travis
Add travis CI
Diffstat (limited to 'testapp/exam/tests.py')
-rw-r--r-- | testapp/exam/tests.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/testapp/exam/tests.py b/testapp/exam/tests.py index 7a8d30c..cd84874 100644 --- a/testapp/exam/tests.py +++ b/testapp/exam/tests.py @@ -20,6 +20,7 @@ def setUpModule(): # create a quiz Quiz.objects.create(start_date='2014-06-16', duration=30, active=False, + attempts_allowed=-1, time_between_attempts=0, description='demo quiz', pass_criteria=40, language='Python', prerequisite=None) @@ -60,10 +61,11 @@ class QuestionTestCases(unittest.TestCase): snippet='def myfunc()') self.question.save() self.question.tags.add('python', 'function') - self.testcase = TestCase(question=self.question, + self.testcase = TestCase(question=self.question, func_name='def myfunc', kw_args='a=10,b=11', pos_args='12,13', expected_answer='15') - answer_data = {"user_answer": "demo_answer", + answer_data = { "test": "", + "user_answer": "demo_answer", "test_parameter": [{"func_name": "def myfunc", "expected_answer": "15", "test_id": self.testcase.id, @@ -71,8 +73,9 @@ class QuestionTestCases(unittest.TestCase): "kw_args": {"a": "10", "b": "11"} }], - "id": self.question.id, - "language": "Python"} + "id": self.question.id, + "ref_code_path": "", + } self.answer_data_json = json.dumps(answer_data) self.user_answer = "demo_answer" @@ -180,6 +183,9 @@ class QuestionPaperTestCases(unittest.TestCase): self.user = User.objects.get(pk=1) + self.attempted_papers = AnswerPaper.objects.filter(question_paper=self.question_paper, + user=self.user) + def test_questionpaper(self): """ Test question paper""" self.assertEqual(self.question_paper.quiz.description, 'demo quiz') @@ -228,7 +234,10 @@ class QuestionPaperTestCases(unittest.TestCase): def test_make_answerpaper(self): """ Test make_answerpaper() method of Question Paper""" - answerpaper = self.question_paper.make_answerpaper(self.user, self.ip) + already_attempted = self.attempted_papers.count() + attempt_num = already_attempted + 1 + answerpaper = self.question_paper.make_answerpaper(self.user, self.ip, + attempt_num) self.assertIsInstance(answerpaper, AnswerPaper) paper_questions = set((answerpaper.questions).split('|')) self.assertEqual(len(paper_questions), 7) @@ -249,13 +258,17 @@ class AnswerPaperTestCases(unittest.TestCase): self.question_paper.save() # create answerpaper - self.answerpaper = AnswerPaper(user=self.user, profile=self.profile, + self.answerpaper = AnswerPaper(user=self.user, questions='1|2|3', question_paper=self.question_paper, start_time='2014-06-13 12:20:19.791297', end_time='2014-06-13 12:50:19.791297', user_ip=self.ip) self.answerpaper.questions_answered = '1' + self.attempted_papers = AnswerPaper.objects.filter(question_paper=self.question_paper, + user=self.user) + already_attempted = self.attempted_papers.count() + self.answerpaper.attempt_number = already_attempted + 1 self.answerpaper.save() # answers for the Answer Paper @@ -271,7 +284,6 @@ class AnswerPaperTestCases(unittest.TestCase): def test_answerpaper(self): """ Test Answer Paper""" self.assertEqual(self.answerpaper.user.username, 'demo_user') - self.assertEqual(self.answerpaper.profile_id, 1) self.assertEqual(self.answerpaper.user_ip, self.ip) questions = self.answerpaper.questions num_questions = len(questions.split('|')) @@ -299,7 +311,8 @@ class AnswerPaperTestCases(unittest.TestCase): def test_skip(self): """ Test skip() method of Answer Paper""" - next_question_id = self.answerpaper.skip() + current_question = self.answerpaper.current_question() + next_question_id = self.answerpaper.skip(current_question) self.assertTrue(next_question_id is not None) self.assertEqual(next_question_id, '3') |