diff options
author | Prabhu Ramachandran | 2018-03-21 18:38:06 +0530 |
---|---|---|
committer | GitHub | 2018-03-21 18:38:06 +0530 |
commit | 4b356aa2f6097cd0f46292218f31ded18b631e53 (patch) | |
tree | 35f7ea09a2464eab2ef185209b7296a63af3f605 /yaksh/test_views.py | |
parent | 30d8671a7c46505561f885e463f60cd04a61a76a (diff) | |
parent | 88fbad3f08dfcf8d139f8bc572860469c64e3104 (diff) | |
download | online_test-4b356aa2f6097cd0f46292218f31ded18b631e53.tar.gz online_test-4b356aa2f6097cd0f46292218f31ded18b631e53.tar.bz2 online_test-4b356aa2f6097cd0f46292218f31ded18b631e53.zip |
Merge pull request #456 from ankitjavalkar/preview-qp
Preview QuestionPaper as an HTML
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r-- | yaksh/test_views.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py index faac617..fd4f040 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -4100,6 +4100,24 @@ class TestQuestionPaper(TestCase): timezone='UTC' ) + self.user2_plaintext_pass = 'demo2' + self.user2 = User.objects.create_user( + username='demo_user2', + password=self.user_plaintext_pass, + first_name='first_name2', + last_name='last_name2', + email='demo2@test.com' + ) + + Profile.objects.create( + user=self.user2, + roll_number=11, + institute='IIT', + department='Chemical', + position='Student', + timezone='UTC' + ) + self.teacher_plaintext_pass = 'demo_teacher' self.teacher = User.objects.create_user( username='demo_teacher', @@ -4254,6 +4272,54 @@ class TestQuestionPaper(TestCase): self.learning_module.delete() self.learning_unit.delete() + def test_preview_questionpaper_correct(self): + self.client.login( + username=self.user.username, + password=self.user_plaintext_pass + ) + + # Should successfully preview question paper + response = self.client.get( + reverse('yaksh:preview_questionpaper', + kwargs={"questionpaper_id": self.question_paper.id} + ) + ) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'yaksh/preview_questionpaper.html') + self.assertEqual( + response.context['questions'], + self.questions_list + ) + self.assertEqual(response.context['paper'], self.question_paper) + + def test_preview_questionpaper_without_moderator(self): + self.client.login( + username=self.user2.username, + password=self.user_plaintext_pass + ) + + # Should raise an HTTP 404 response + response = self.client.get( + reverse('yaksh:preview_questionpaper', + kwargs={"questionpaper_id": self.question_paper.id} + ) + ) + self.assertEqual(response.status_code, 404) + + def test_preview_qustionpaper_without_quiz_owner(self): + self.client.login( + username=self.teacher.username, + password=self.teacher_plaintext_pass + ) + + # Should raise an HTTP 404 response + response = self.client.get( + reverse('yaksh:preview_questionpaper', + kwargs={"questionpaper_id": self.question_paper.id} + ) + ) + self.assertEqual(response.status_code, 404) + def test_mcq_attempt_right_after_wrong(self): """ Case:- Check if answerpaper and answer marks are updated after attempting same mcq question with wrong answer and then right |