diff options
author | Prabhu Ramachandran | 2018-02-15 19:28:53 +0530 |
---|---|---|
committer | GitHub | 2018-02-15 19:28:53 +0530 |
commit | 3e4fa8a4b6f0b16731f27b724fad119ee74dc618 (patch) | |
tree | 7e326dcfa3897f624c8c3cf637543646b86b7491 /yaksh/test_models.py | |
parent | 7a89ac6dabe7d2b8d914c8efde30c65f365bd771 (diff) | |
parent | 617d09ca9b05185d9a2310c106360091ed8a1b1a (diff) | |
download | online_test-3e4fa8a4b6f0b16731f27b724fad119ee74dc618.tar.gz online_test-3e4fa8a4b6f0b16731f27b724fad119ee74dc618.tar.bz2 online_test-3e4fa8a4b6f0b16731f27b724fad119ee74dc618.zip |
Merge pull request #436 from adityacp/fixes_lesson_feature
Additions and fixes for lesson feature
Diffstat (limited to 'yaksh/test_models.py')
-rw-r--r-- | yaksh/test_models.py | 44 |
1 files changed, 35 insertions, 9 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py index 2aa55d4..cd4279b 100644 --- a/yaksh/test_models.py +++ b/yaksh/test_models.py @@ -100,6 +100,7 @@ def setUpModule(): course.students.add(course_user) course.save() LessonFile.objects.create(lesson=lesson) + CourseStatus.objects.create(course=course, user=course_user) def tearDownModule(): @@ -137,6 +138,13 @@ class LearningModuleTestCases(unittest.TestCase): self.quiz = Quiz.objects.get(description='demo quiz 1') self.lesson = Lesson.objects.get(name='L1') self.course = Course.objects.get(name='Python Course') + self.course_status = CourseStatus.objects.get( + course=self.course, user=self.student) + + def tearDown(self): + # Remove unit from course status completed units + self.course_status.completed_units.remove(self.learning_unit_one) + self.course_status.completed_units.remove(self.learning_unit_two) def test_learning_module(self): self.assertEqual(self.learning_module.description, 'module one') @@ -197,7 +205,7 @@ class LearningModuleTestCases(unittest.TestCase): # Then self.assertEqual(unit, next_unit) - def test_get_status(self): + def test_get_module_status(self): # Given module_status = 'not attempted' # When @@ -205,6 +213,29 @@ class LearningModuleTestCases(unittest.TestCase): # Then self.assertEqual(status, module_status) + # Module in progress + + # Given + self.course_status.completed_units.add(self.learning_unit_one) + # When + status = self.learning_module.get_status(self.student, self.course) + # Then + self.assertEqual("inprogress", status) + + # Module is completed + + # Given + self.course_status.completed_units.add(self.learning_unit_two) + # When + status = self.learning_module.get_status(self.student, self.course) + # Then + self.assertEqual("completed", status) + + # Module with no units + self.course.learning_module.add(self.learning_module_two) + status = self.learning_module_two.get_status(self.student, self.course) + self.assertEqual("no units", status) + def test_module_completion_percent(self): # for module without learning units percent = self.learning_module_two.get_module_complete_percent( @@ -213,17 +244,12 @@ class LearningModuleTestCases(unittest.TestCase): self.assertEqual(percent, 0) # for module with learning units - lesson = Lesson.objects.get(name='L1') - self.completed_unit = LearningUnit.objects.get(lesson=lesson) - - course_status = CourseStatus.objects.create( - course=self.course, user=self.student) - course_status.completed_units.add(self.completed_unit) - + self.course_status.completed_units.add(self.learning_unit_one) + self.course_status.completed_units.add(self.learning_unit_two) percent = self.learning_module.get_module_complete_percent( self.course, self.student ) - self.assertEqual(percent, 50) + self.assertEqual(percent, 100) class LearningUnitTestCases(unittest.TestCase): |