summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2018-02-15 19:23:10 +0530
committerGitHub2018-02-15 19:23:10 +0530
commit7a89ac6dabe7d2b8d914c8efde30c65f365bd771 (patch)
tree8cad0e90ca8bda9aae11425ef6231c69ec7e5bb0 /yaksh/test_models.py
parent0757a779f5acb41ed52263e3c8406c24918a1e88 (diff)
parent2c53d636aa4a3f36586910e1d3ef5276a7efc337 (diff)
downloadonline_test-7a89ac6dabe7d2b8d914c8efde30c65f365bd771.tar.gz
online_test-7a89ac6dabe7d2b8d914c8efde30c65f365bd771.tar.bz2
online_test-7a89ac6dabe7d2b8d914c8efde30c65f365bd771.zip
Merge pull request #430 from maheshgudi/multiple_answerpaper
Fix multiple Answerpaper objects returned error
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index df8372c..2aa55d4 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -12,6 +12,7 @@ from datetime import datetime, timedelta
from django.utils import timezone
import pytz
from django.contrib.auth.models import Group
+from django.db import IntegrityError
from django.core.files import File
from django.forms.models import model_to_dict
from textwrap import dedent
@@ -835,7 +836,8 @@ class AnswerPaperTestCases(unittest.TestCase):
question_paper=self.question_paper,
start_time=self.start_time,
end_time=self.end_time,
- user_ip=self.ip
+ user_ip=self.ip,
+ course=self.course
)
self.attempted_papers = AnswerPaper.objects.filter(
question_paper=self.question_paper,
@@ -1375,6 +1377,17 @@ class AnswerPaperTestCases(unittest.TestCase):
self.assertEqual(self.user2_answerpaper2.current_question(),
self.question1)
+ def test_duplicate_attempt_answerpaper(self):
+ with self.assertRaises(IntegrityError):
+ new_answerpaper = AnswerPaper.objects.create(
+ user=self.answerpaper.user,
+ question_paper=self.answerpaper.question_paper,
+ attempt_number=self.answerpaper.attempt_number,
+ start_time=self.answerpaper.start_time,
+ end_time=self.answerpaper.end_time,
+ course=self.answerpaper.course
+ )
+
###############################################################################
class CourseTestCases(unittest.TestCase):