diff options
author | adityacp | 2018-01-19 12:04:08 +0530 |
---|---|---|
committer | adityacp | 2018-01-19 12:22:09 +0530 |
commit | 6da1f77a6a1a2bffb85d5395f2703f186b18cb4a (patch) | |
tree | 73b2339ffda3002011a9548b7b60eb279920dfeb | |
parent | 9f0724354ae2801be02c5c8b8762d76ef6ce589d (diff) | |
download | online_test-6da1f77a6a1a2bffb85d5395f2703f186b18cb4a.tar.gz online_test-6da1f77a6a1a2bffb85d5395f2703f186b18cb4a.tar.bz2 online_test-6da1f77a6a1a2bffb85d5395f2703f186b18cb4a.zip |
Improve views test case for questionpaper
-rw-r--r-- | yaksh/test_views.py | 24 | ||||
-rw-r--r-- | yaksh/views.py | 2 |
2 files changed, 21 insertions, 5 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py index 5c1c475..dad5e89 100644 --- a/yaksh/test_views.py +++ b/yaksh/test_views.py @@ -4064,9 +4064,6 @@ class TestQuestionPaper(TestCase): name="Python Course", enrollment="Open Enrollment", creator=self.user) - # Add teacher to the course - self.course.teachers.add(self.teacher) - self.quiz = Quiz.objects.create( start_date_time=datetime(2014, 10, 9, 10, 8, 15, 0, tzone), end_date_time=datetime(2015, 10, 9, 10, 8, 15, 0, tzone), @@ -4475,12 +4472,31 @@ class TestQuestionPaper(TestCase): "questionpaper_id": self.question_paper.id})) self.assertEqual(response.status_code, 404) - # Should allow course teacher to edit question paper self.client.login( username=self.teacher.username, password=self.teacher_plaintext_pass ) + # Should not allow teacher to view question paper + response = self.client.get( + reverse('yaksh:designquestionpaper', + kwargs={"quiz_id": self.quiz.id, + "questionpaper_id": self.question_paper.id})) + + self.assertEqual(response.status_code, 404) + + # Should not allow teacher to view question paper + response = self.client.get( + reverse('yaksh:designquestionpaper', + kwargs={"quiz_id": self.quiz.id, + "course_id": self.course.id, + "questionpaper_id": self.question_paper.id})) + + self.assertEqual(response.status_code, 404) + + # Should allow course teacher to view question paper + # Add teacher to the course + self.course.teachers.add(self.teacher) response = self.client.get( reverse('yaksh:designquestionpaper', kwargs={"quiz_id": self.quiz.id, diff --git a/yaksh/views.py b/yaksh/views.py index 40bec2e..4ff1032 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1305,7 +1305,7 @@ def design_questionpaper(request, quiz_id, questionpaper_id=None, if course_id: course = get_object_or_404(Course, pk=course_id) if not course.is_creator(user) and not course.is_teacher(user): - raise Http404('This quiz does not belong to you') + raise Http404('This Course does not belong to you') filter_form = QuestionFilterForm(user=user) questions = None |