summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authorprathamesh2017-01-13 16:49:16 +0530
committerprathamesh2017-01-13 16:49:16 +0530
commitc70c38dd55e159a5e7aa6706bb23bb8e70ca10bd (patch)
treef85d78faa6d51046b79e26ee59efa15e3c16bd75 /yaksh/test_models.py
parent5ee9b4647c7f1ba9803a95ad3871f6acfc92c1c0 (diff)
parent0e3e0cdbf322df9b5c8b7da0301cebe71eadcbe9 (diff)
downloadonline_test-c70c38dd55e159a5e7aa6706bb23bb8e70ca10bd.tar.gz
online_test-c70c38dd55e159a5e7aa6706bb23bb8e70ca10bd.tar.bz2
online_test-c70c38dd55e159a5e7aa6706bb23bb8e70ca10bd.zip
Merge branch 'master' of https://github.com/FOSSEE/online_test into UI-modifications-phase-2
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py61
1 files changed, 46 insertions, 15 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index e95528b..1a6bcba 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -98,7 +98,6 @@ class QuestionTestCases(unittest.TestCase):
language='Python',
type='Code',
active=True,
- test_case_type='standardtestcase',
description='Write a function',
points=1.0,
snippet='def myfunc()',
@@ -111,7 +110,6 @@ class QuestionTestCases(unittest.TestCase):
type='code',
active=True,
description='factorial of a no',
- test_case_type='standardtestcase',
points=2.0,
snippet='def fact()',
user=self.user2
@@ -196,7 +194,6 @@ class QuestionTestCases(unittest.TestCase):
self.assertEqual(self.question2.points, q['points'])
self.assertTrue(self.question2.active)
self.assertEqual(self.question2.snippet, q['snippet'])
- self.assertEqual(self.question2.test_case_type, q['test_case_type'])
self.assertEqual(os.path.basename(que_file.file.path), q['files'][0][0])
self.assertEqual([case.get_field_value() for case in test_case], q['testcase'])
for file in zip_file.namelist():
@@ -536,22 +533,22 @@ class AnswerPaperTestCases(unittest.TestCase):
)
self.mcc_based_testcase.save()
- def test_validate_and_regrade_mcc_question(self):
+ def test_validate_and_regrade_mcc_correct_answer(self):
# Given
mcc_answer = ['a']
self.answer = Answer(question=self.question3,
- answer=mcc_answer,
- )
+ answer=mcc_answer,
+ )
self.answer.save()
self.answerpaper.answers.add(self.answer)
# When
json_data = None
- correct, result = self.answerpaper.validate_answer(mcc_answer,
- self.question3, json_data)
+ result = self.answerpaper.validate_answer(mcc_answer,
+ self.question3, json_data
+ )
# Then
- self.assertTrue(correct)
self.assertTrue(result['success'])
self.assertEqual(result['error'], ['Correct answer'])
self.answer.correct = True
@@ -573,7 +570,7 @@ class AnswerPaperTestCases(unittest.TestCase):
self.assertEqual(self.answer.marks, 0)
self.assertFalse(self.answer.correct)
- def test_validate_and_regrade_mcq_question(self):
+ def test_validate_and_regrade_mcq_correct_answer(self):
# Given
mcq_answer = 'a'
self.answer = Answer(question=self.question2,
@@ -584,11 +581,11 @@ class AnswerPaperTestCases(unittest.TestCase):
# When
json_data = None
- correct, result = self.answerpaper.validate_answer(mcq_answer,
- self.question2, json_data)
+ result = self.answerpaper.validate_answer(mcq_answer,
+ self.question2, json_data
+ )
# Then
- self.assertTrue(correct)
self.assertTrue(result['success'])
self.answer.correct = True
self.answer.marks = 1
@@ -610,6 +607,42 @@ class AnswerPaperTestCases(unittest.TestCase):
self.assertFalse(self.answer.correct)
+ def test_mcq_incorrect_answer(self):
+ # Given
+ mcq_answer = 'a'
+ self.answer = Answer(question=self.question2,
+ answer=mcq_answer,
+ )
+ self.answer.save()
+ self.answerpaper.answers.add(self.answer)
+
+ # When
+ json_data = None
+ result = self.answerpaper.validate_answer(mcq_answer,
+ self.question2, json_data
+ )
+
+ # Then
+ self.assertTrue(result['success'])
+
+ def test_mcc_incorrect_answer(self):
+ # Given
+ mcc_answer = ['b']
+ self.answer = Answer(question=self.question3,
+ answer=mcc_answer,
+ )
+ self.answer.save()
+ self.answerpaper.answers.add(self.answer)
+
+ # When
+ json_data = None
+ result = self.answerpaper.validate_answer(mcc_answer,
+ self.question3, json_data
+ )
+
+ # Then
+ self.assertFalse(result['success'])
+
def test_answerpaper(self):
""" Test Answer Paper"""
self.assertEqual(self.answerpaper.user.username, 'demo_user')
@@ -861,7 +894,6 @@ class TestCaseTestCases(unittest.TestCase):
active=True,
description='Write a function',
points=1.0,
- test_case_type="standardtestcase",
user=self.user,
snippet='def myfunc()'
)
@@ -871,7 +903,6 @@ class TestCaseTestCases(unittest.TestCase):
active=True,
description='Write to standard output',
points=1.0,
- test_case_type="stdiobasedtestcase",
user=self.user,
snippet='def myfunc()'
)