diff options
author | CruiseDevice | 2019-01-07 15:32:31 +0530 |
---|---|---|
committer | CruiseDevice | 2019-01-28 13:07:02 +0530 |
commit | 0a106ab44ec983f4ebebea9b6b1e4b49fedcb473 (patch) | |
tree | 3accf1fa5d91fc63afaed49979e6a3335166766b | |
parent | a4c6a0a3c013f02c7cdd1d365a180ff6de121d6e (diff) | |
download | online_test-0a106ab44ec983f4ebebea9b6b1e4b49fedcb473.tar.gz online_test-0a106ab44ec983f4ebebea9b6b1e4b49fedcb473.tar.bz2 online_test-0a106ab44ec983f4ebebea9b6b1e4b49fedcb473.zip |
Add test for new model function
- Adds test for get_categorized_question_indices function in models.
-rw-r--r-- | yaksh/test_models.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py index aea47de..3ae181c 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -4,7 +4,7 @@ from yaksh.models import User, Profile, Question, Quiz, QuestionPaper,\ QuestionSet, AnswerPaper, Answer, Course, StandardTestCase,\ StdIOBasedTestCase, FileUpload, McqTestCase, AssignmentUpload,\ LearningModule, LearningUnit, Lesson, LessonFile, CourseStatus, \ - create_group + create_group, legend_display_types from yaksh.code_server import ( ServerPool, get_result as get_result_from_code_server ) @@ -21,6 +21,7 @@ import os import shutil import tempfile from threading import Thread +from collections import Counter, defaultdict from yaksh import settings @@ -1583,6 +1584,20 @@ class AnswerPaperTestCases(unittest.TestCase): course=self.answerpaper.course ) + def test_get_categorized_question_indices(self): + all_questions = self.answerpaper.get_all_ordered_questions() + categorized_question_indices = \ + self.answerpaper.get_categorized_question_indices() + questions = all_questions[0:4] + category_question_map = defaultdict(lambda: []) + for index, question in enumerate(questions, 1): + category_question_map[ + legend_display_types[question.type]["label"] + ].append(index) + category_question_map = dict(category_question_map) + self.assertDictEqual( + category_question_map, categorized_question_indices) + ############################################################################### class CourseTestCases(unittest.TestCase): |