summaryrefslogtreecommitdiff
path: root/yaksh/test_views.py
diff options
context:
space:
mode:
authoradityacp2020-08-28 11:26:51 +0530
committeradityacp2020-08-28 11:26:51 +0530
commite3c3a0d9f7819f851890ea2611ba12b4f6255f06 (patch)
treea5a6bfd8bbdbdb358c8a8912261ab4e7407606c0 /yaksh/test_views.py
parent620df8d25a82ceb99eb7cd17535c20998e212191 (diff)
downloadonline_test-e3c3a0d9f7819f851890ea2611ba12b4f6255f06.tar.gz
online_test-e3c3a0d9f7819f851890ea2611ba12b4f6255f06.tar.bz2
online_test-e3c3a0d9f7819f851890ea2611ba12b4f6255f06.zip
fix design question paper views and tests
Diffstat (limited to 'yaksh/test_views.py')
-rw-r--r--yaksh/test_views.py54
1 files changed, 30 insertions, 24 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 5876f03..df408bb 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -5964,12 +5964,11 @@ class TestQuestionPaper(TestCase):
'add-random': ['']}
)
- self.assertEqual(response.status_code, 200)
- self.assertTemplateUsed(response, 'yaksh/design_questionpaper.html')
- random_set = response.context['random_sets'][0]
- added_random_ques = random_set.questions.all()
- self.assertIn(self.random_que1, added_random_ques)
- self.assertIn(self.random_que2, added_random_ques)
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue(
+ self.question_paper.random_questions.filter(
+ id__in=[self.random_que1.id, self.random_que2.id]).exists()
+ )
# Check if questions already exists
self.client.login(
@@ -5996,10 +5995,11 @@ class TestQuestionPaper(TestCase):
data={'checked_ques': [self.fixed_que.id],
'add-fixed': ''}
)
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.context['qpaper'], self.fixed_question_paper)
- self.assertEqual(response.context['fixed_questions'][0],
- self.fixed_que)
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue(
+ self.fixed_question_paper.fixed_questions.filter(
+ id=self.fixed_que.id).exists()
+ )
# Add one more fixed question in question paper
response = self.client.post(
@@ -6010,10 +6010,11 @@ class TestQuestionPaper(TestCase):
data={'checked_ques': [self.question_float.id],
'add-fixed': ''}
)
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.context['qpaper'], self.fixed_question_paper)
- self.assertEqual(response.context['fixed_questions'],
- [self.fixed_que, self.question_float])
+ self.assertEqual(response.status_code, 302)
+ self.assertTrue(
+ self.fixed_question_paper.fixed_questions.filter(
+ id=self.question_float.id).exists()
+ )
# Remove fixed question from question paper
response = self.client.post(
@@ -6024,10 +6025,11 @@ class TestQuestionPaper(TestCase):
data={'added-questions': [self.fixed_que.id],
'remove-fixed': ''}
)
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.context['qpaper'], self.fixed_question_paper)
- self.assertEqual(response.context['fixed_questions'],
- [self.question_float])
+ self.assertEqual(response.status_code, 302)
+ self.assertFalse(
+ self.fixed_question_paper.fixed_questions.filter(
+ id=self.fixed_que.id).exists()
+ )
# Remove one more fixed question from question paper
response = self.client.post(
@@ -6038,9 +6040,11 @@ class TestQuestionPaper(TestCase):
data={'added-questions': [self.question_float.id],
'remove-fixed': ''}
)
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.context['qpaper'], self.fixed_question_paper)
- self.assertEqual(response.context['fixed_questions'], [])
+ self.assertEqual(response.status_code, 302)
+ self.assertFalse(
+ self.fixed_question_paper.fixed_questions.filter(
+ id=self.question_float.id).exists()
+ )
# Remove random questions from question paper
random_que_set = self.question_paper.random_questions.all().first()
@@ -6052,9 +6056,11 @@ class TestQuestionPaper(TestCase):
data={'random_sets': random_que_set.id,
'remove-random': ''}
)
- self.assertEqual(response.status_code, 200)
- self.assertEqual(response.context['qpaper'], self.question_paper)
- self.assertEqual(len(response.context['random_sets']), 0)
+ self.assertEqual(response.status_code, 302)
+ self.assertFalse(
+ self.question_paper.random_questions.filter(
+ id=random_que_set.id).exists()
+ )
class TestLearningModule(TestCase):