summaryrefslogtreecommitdiff
path: root/yaksh/test_models.py
diff options
context:
space:
mode:
authoradityacp2018-05-25 11:57:11 +0530
committeradityacp2018-06-07 14:50:47 +0530
commita2769e56ab99427beb196b85bf3fc125ffd9bac2 (patch)
tree3e524f66fc84f0f220bbae9f3235e5e6138044d7 /yaksh/test_models.py
parent0adb0d3b79980544bb5a724ce3b106dbd8e01c9c (diff)
downloadonline_test-a2769e56ab99427beb196b85bf3fc125ffd9bac2.tar.gz
online_test-a2769e56ab99427beb196b85bf3fc125ffd9bac2.tar.bz2
online_test-a2769e56ab99427beb196b85bf3fc125ffd9bac2.zip
Add tests for models and cpp, java evaluators
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r--yaksh/test_models.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 132537d..210456f 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -356,6 +356,23 @@ class QuestionTestCases(unittest.TestCase):
self.yaml_questions_data_with_missing_fields = yaml.safe_dump_all(
questions_data_with_missing_fields
)
+ self.bad_yaml_question_data = '''[{
+ "active": True, "points": 1.0, "description" "factorial of a no",
+ "language": "Python", "type": "Code",
+ "testcase": self.test_case_upload_data,
+ "summary": "bad yaml"
+ }]'''
+
+ self.test_case_without_type = [{"test_case": "assert fact(3)==6",
+ "test_case_args": "",
+ "weight": 1.0
+ }]
+ self.yaml_question_data_without_test_case_type = yaml.safe_dump_all([{
+ "active": True, "points": 1.0, "description": "factorial of a no",
+ "language": "Python", "type": "Code",
+ "testcase": self.test_case_without_type,
+ "summary": "bad yaml"
+ }])
def tearDown(self):
shutil.rmtree(self.load_tmp_path)
@@ -460,6 +477,23 @@ class QuestionTestCases(unittest.TestCase):
tags = question_data.tags.all().values_list("name", flat=True)
self.assertListEqual(list(tags), [])
+ def test_load_questions_with_bad_yaml(self):
+ """
+ Test if yaml file is parsed correctly
+ """
+ question = Question()
+ msg = question.load_questions(
+ self.bad_yaml_question_data,
+ self.user1
+ )
+ self.assertIn("Error Parsing Yaml", msg)
+
+ msg = question.load_questions(
+ self.yaml_question_data_without_test_case_type,
+ self.user1
+ )
+ self.assertEqual(msg, "Unable to parse test case data")
+
###############################################################################
class QuizTestCases(unittest.TestCase):