summaryrefslogtreecommitdiff
path: root/yaksh/test_views.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r--yaksh/test_views.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 274bcda..4c1f5b9 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -420,10 +420,14 @@ class TestStudentDashboard(TestCase):
response = self.client.get(reverse('yaksh:quizlist_user'),
follow=True
)
+ courses_in_context = {
+ 'data': self.course,
+ 'completion_percentage': None,
+ }
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "yaksh/quizzes_user.html")
self.assertEqual(response.context['title'], 'All Courses')
- self.assertEqual(response.context['courses'][0], self.course)
+ self.assertEqual(response.context['courses'][0], courses_in_context)
def test_student_dashboard_enrolled_courses_get(self):
"""
@@ -439,10 +443,14 @@ class TestStudentDashboard(TestCase):
kwargs={'enrolled': "enrolled"}),
follow=True
)
+ courses_in_context = {
+ 'data': self.course,
+ 'completion_percentage': 0,
+ }
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "yaksh/quizzes_user.html")
self.assertEqual(response.context['title'], 'Enrolled Courses')
- self.assertEqual(response.context['courses'][0], self.course)
+ self.assertEqual(response.context['courses'][0], courses_in_context)
def test_student_dashboard_hidden_courses_post(self):
"""
@@ -456,10 +464,14 @@ class TestStudentDashboard(TestCase):
response = self.client.post(reverse('yaksh:quizlist_user'),
data={'course_code': 'hide'}
)
+ courses_in_context = {
+ 'data': self.hidden_course,
+ 'completion_percentage': None,
+ }
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "yaksh/quizzes_user.html")
self.assertEqual(response.context['title'], 'Search')
- self.assertEqual(response.context['courses'][0], self.hidden_course)
+ self.assertEqual(response.context['courses'][0], courses_in_context)
class TestMonitor(TestCase):
@@ -5017,19 +5029,25 @@ class TestQuestionPaper(TestCase):
)
self.assertEqual(response.status_code, 404)
- def test_preview_qustionpaper_without_quiz_owner(self):
+ def test_preview_questionpaper_without_quiz_owner(self):
self.client.login(
username=self.teacher.username,
password=self.teacher_plaintext_pass
)
- # Should raise an HTTP 404 response
+ # Should pass successfully
response = self.client.get(
reverse('yaksh:preview_questionpaper',
kwargs={"questionpaper_id": self.question_paper.id}
)
)
- self.assertEqual(response.status_code, 404)
+ 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_mcq_attempt_right_after_wrong(self):
""" Case:- Check if answerpaper and answer marks are updated after