summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2018-02-08 11:56:11 +0530
committeradityacp2018-02-08 11:56:11 +0530
commite1b60921ba995148e0741637011651eb21eb49be (patch)
tree23244170180a12650590a7089de12607c620610a /yaksh
parente1f4ffc3ab43d02115e6c496bf08bea1e52af2ef (diff)
downloadonline_test-e1b60921ba995148e0741637011651eb21eb49be.tar.gz
online_test-e1b60921ba995148e0741637011651eb21eb49be.tar.bz2
online_test-e1b60921ba995148e0741637011651eb21eb49be.zip
Change in test_views and test_models
- Add views test to check active status for lesson and learning module - Change models test for module get_status method
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/test_models.py35
-rw-r--r--yaksh/test_views.py24
2 files changed, 51 insertions, 8 deletions
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 7086a1e..d6fac96 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -99,6 +99,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():
@@ -136,6 +137,8 @@ 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 test_learning_module(self):
self.assertEqual(self.learning_module.description, 'module one')
@@ -204,6 +207,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(
@@ -212,17 +238,10 @@ 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)
-
percent = self.learning_module.get_module_complete_percent(
self.course, self.student
)
- self.assertEqual(percent, 50)
+ self.assertEqual(percent, 100)
class LearningUnitTestCases(unittest.TestCase):
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 9be8d13..3b27338 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -5079,6 +5079,30 @@ class TestLessons(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["msg"], err_msg)
+ # Check if lesson is active
+ self.lesson.active = False
+ self.lesson.save()
+ response = self.client.get(
+ reverse('yaksh:show_lesson',
+ kwargs={"lesson_id": self.lesson.id,
+ "module_id": self.learning_module.id,
+ "course_id": self.course.id}))
+ err_msg = "{0} is not active".format(self.lesson.name)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.context["msg"], err_msg)
+
+ # Check if module is active
+ self.learning_module2.active = False
+ self.learning_module2.save()
+ response = self.client.get(
+ reverse('yaksh:show_lesson',
+ kwargs={"lesson_id": self.lesson2.id,
+ "module_id": self.learning_module2.id,
+ "course_id": self.course.id}))
+ err_msg = "{0} is not active".format(self.learning_module2.name)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.context["msg"], err_msg)
+
def test_show_all_lessons(self):
""" Moderator should be able to see all created lessons"""
self.client.login(