summaryrefslogtreecommitdiff
path: root/yaksh/test_views.py
diff options
context:
space:
mode:
authoradityacp2020-04-20 16:33:55 +0530
committeradityacp2020-04-20 16:33:55 +0530
commitaa55eca2e8c745ef22226b4e41eae5f060154aa1 (patch)
tree93d3af65fa461b4a3564ea4cea4a001ceaca273b /yaksh/test_views.py
parent348f2bc4f727b27abd9878334e886527479d260c (diff)
downloadonline_test-aa55eca2e8c745ef22226b4e41eae5f060154aa1.tar.gz
online_test-aa55eca2e8c745ef22226b4e41eae5f060154aa1.tar.bz2
online_test-aa55eca2e8c745ef22226b4e41eae5f060154aa1.zip
Change tasks, test_views, templates
- Change notification message in celery task - Fix views test for regrade - Change name from Grader to Quizzes in manage.html navbar
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r--yaksh/test_views.py88
1 files changed, 26 insertions, 62 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 8f811c5..b137435 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -32,6 +32,8 @@ from yaksh.models import (
from yaksh.views import add_as_moderator
from yaksh.decorators import user_has_profile
+from notifications_plugin.models import Notification
+
class TestUserRegistration(TestCase):
def setUp(self):
@@ -575,9 +577,9 @@ class TestMonitor(TestCase):
)
self.assertEqual(response.status_code, 404)
- def test_monitor_display_quizzes(self):
+ def test_monitor_quiz_not_found(self):
"""
- Check all the available quizzes in monitor
+ Check if quiz is not found
"""
self.client.login(
username=self.user.username,
@@ -586,10 +588,7 @@ class TestMonitor(TestCase):
response = self.client.get(reverse('yaksh:monitor'),
follow=True
)
- self.assertEqual(response.status_code, 200)
- self.assertTemplateUsed(response, "yaksh/monitor.html")
- self.assertEqual(response.context['objects'][0], self.course)
- self.assertEqual(response.context['msg'], "Monitor")
+ self.assertEqual(response.status_code, 404)
def test_monitor_display_quiz_results(self):
"""
@@ -3687,41 +3686,20 @@ class TestGrader(TestCase):
AnswerPaper.objects.all().delete()
self.mod_group.delete()
- def test_grader_denies_anonymous(self):
- # Given
- redirect_destination = ('/exam/login/?next=/exam/manage/grader/')
-
- # When
- response = self.client.get(reverse('yaksh:grader'), follow=True)
-
- # Then
- self.assertRedirects(response, redirect_destination)
-
- def test_grader_denies_students(self):
- # Given
- self.client.login(
- username=self.student.username,
- password=self.student_plaintext_pass
- )
-
- # When
- response = self.client.get(reverse('yaksh:grader'), follow=True)
-
- # Then
- self.assertEqual(response.status_code, 404)
-
def test_regrade_denies_anonymous(self):
# Given
- url = "/exam/login/?next=/exam/manage/regrade/answerpaper"
+ url = "/exam/login/?next=/exam/manage/regrade/user/question"
redirect_destination = (
- url + "/{}/{}/{}/".format(
- self.course.id, self.question.id, self.answerpaper.id)
+ url + "/{}/{}/{}/{}/".format(
+ self.course.id, self.question_paper.id,
+ self.answerpaper.id, self.question.id)
)
# When
response = self.client.get(
- reverse('yaksh:regrade',
+ reverse('yaksh:regrade_by_question',
kwargs={'course_id': self.course.id,
+ 'questionpaper_id': self.question_paper.id,
'question_id': self.question.id,
'answerpaper_id': self.answerpaper.id}),
follow=True
@@ -3739,8 +3717,9 @@ class TestGrader(TestCase):
# When
response = self.client.get(
- reverse('yaksh:regrade',
+ reverse('yaksh:regrade_by_question',
kwargs={'course_id': self.course.id,
+ 'questionpaper_id': self.question_paper.id,
'question_id': self.question.id,
'answerpaper_id': self.answerpaper.id}),
follow=True
@@ -3749,21 +3728,6 @@ class TestGrader(TestCase):
# Then
self.assertEqual(response.status_code, 404)
- def test_grader_by_moderator(self):
- # Given
- self.client.login(
- username=self.user1.username,
- password=self.user1_plaintext_pass
- )
-
- # When
- response = self.client.get(reverse('yaksh:grader'), follow=True)
-
- # Then
- self.assertEqual(response.status_code, 200)
- self.assertTrue('courses' in response.context)
- self.assertTemplateUsed(response, 'yaksh/regrade.html')
-
def test_regrade_by_moderator(self):
# Given
self.client.login(
@@ -3773,44 +3737,43 @@ class TestGrader(TestCase):
# When
response = self.client.get(
- reverse('yaksh:regrade',
+ reverse('yaksh:regrade_by_question',
kwargs={'course_id': self.course.id,
+ 'questionpaper_id': self.question_paper.id,
'question_id': self.question.id,
'answerpaper_id': self.answerpaper.id}),
follow=True)
# Then
+ messages = [m.message for m in get_messages(response.wsgi_request)]
self.assertEqual(response.status_code, 200)
- self.assertTrue('courses' in response.context)
- self.assertTrue('details' in response.context)
- self.assertTemplateUsed(response, 'yaksh/regrade.html')
+ self.assertIn("demo quiz is submitted for re-evaluation", messages[0])
# When
response = self.client.get(
- reverse('yaksh:regrade',
+ reverse('yaksh:regrade_by_user',
kwargs={'course_id': self.course.id,
+ 'questionpaper_id': self.question_paper.id,
'answerpaper_id': self.answerpaper.id}),
follow=True)
# Then
+ messages = [m.message for m in get_messages(response.wsgi_request)]
self.assertEqual(response.status_code, 200)
- self.assertTrue('courses' in response.context)
- self.assertTrue('details' in response.context)
- self.assertTemplateUsed(response, 'yaksh/regrade.html')
+ self.assertIn("demo quiz is submitted for re-evaluation", messages[0])
# When
response = self.client.get(
- reverse('yaksh:regrade',
+ reverse('yaksh:regrade_by_quiz',
kwargs={'course_id': self.course.id,
'question_id': self.question.id,
'questionpaper_id': self.question_paper.id}),
follow=True)
# Then
+ messages = [m.message for m in get_messages(response.wsgi_request)]
self.assertEqual(response.status_code, 200)
- self.assertTrue('courses' in response.context)
- self.assertTrue('details' in response.context)
- self.assertTemplateUsed(response, 'yaksh/regrade.html')
+ self.assertIn("demo quiz is submitted for re-evaluation", messages[0])
def test_regrade_denies_moderator_not_in_course(self):
# Given
@@ -3822,8 +3785,9 @@ class TestGrader(TestCase):
self.mod_group.user_set.remove(self.user2)
# When
response = self.client.get(
- reverse('yaksh:regrade',
+ reverse('yaksh:regrade_by_question',
kwargs={'course_id': self.course.id,
+ 'questionpaper_id': self.question_paper.id,
'question_id': self.question.id,
'answerpaper_id': self.answerpaper.id}),
follow=True)