Commit 3559bd1e by Mushtaq Ali

Refactor test to check support for both modulestore and is_self_paced method improvement

parent df0b983e
...@@ -463,4 +463,4 @@ def is_self_paced(course): ...@@ -463,4 +463,4 @@ def is_self_paced(course):
""" """
Returns True if course is self-paced, False otherwise. Returns True if course is self-paced, False otherwise.
""" """
return course.self_paced and SelfPacedConfiguration.current().enabled if course else False return course and course.self_paced and SelfPacedConfiguration.current().enabled
...@@ -1848,6 +1848,7 @@ class TestLibraryXBlockCreation(ItemTest): ...@@ -1848,6 +1848,7 @@ class TestLibraryXBlockCreation(ItemTest):
self.assertFalse(lib.children) self.assertFalse(lib.children)
@ddt.ddt
class TestXBlockPublishingInfo(ItemTest): class TestXBlockPublishingInfo(ItemTest):
""" """
Unit tests for XBlock's outline handling. Unit tests for XBlock's outline handling.
...@@ -2171,7 +2172,8 @@ class TestXBlockPublishingInfo(ItemTest): ...@@ -2171,7 +2172,8 @@ class TestXBlockPublishingInfo(ItemTest):
self._verify_has_staff_only_message(xblock_info, True, path=self.FIRST_SUBSECTION_PATH) self._verify_has_staff_only_message(xblock_info, True, path=self.FIRST_SUBSECTION_PATH)
self._verify_has_staff_only_message(xblock_info, True, path=self.FIRST_UNIT_PATH) self._verify_has_staff_only_message(xblock_info, True, path=self.FIRST_UNIT_PATH)
def test_self_paced_item_visibility_state(self): @ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_self_paced_item_visibility_state(self, store_type):
""" """
Test that in self-paced course, item has `live` visibility state. Test that in self-paced course, item has `live` visibility state.
Test that when item was initially in `scheduled` state in instructor mode, change course pacing to self-paced, Test that when item was initially in `scheduled` state in instructor mode, change course pacing to self-paced,
...@@ -2179,20 +2181,22 @@ class TestXBlockPublishingInfo(ItemTest): ...@@ -2179,20 +2181,22 @@ class TestXBlockPublishingInfo(ItemTest):
""" """
SelfPacedConfiguration(enabled=True).save() SelfPacedConfiguration(enabled=True).save()
# Create chapter and setup future release date to make chapter in scheduled state with self.store.default_store(store_type):
chapter = self._create_child(self.course, 'chapter', "Test Chapter") # Create course, chapter and setup future release date to make chapter in scheduled state
self._set_release_date(chapter.location, datetime.now(UTC) + timedelta(days=1)) course = CourseFactory.create()
chapter = self._create_child(course, 'chapter', "Test Chapter")
# Check that has scheduled state self._set_release_date(chapter.location, datetime.now(UTC) + timedelta(days=1))
xblock_info = self._get_xblock_info(chapter.location)
self._verify_visibility_state(xblock_info, VisibilityState.ready) # Check that has scheduled state
self.assertFalse(self.course.self_paced) xblock_info = self._get_xblock_info(chapter.location)
self._verify_visibility_state(xblock_info, VisibilityState.ready)
# Change course pacing to self paced self.assertFalse(course.self_paced)
self.course.self_paced = True
self.store.update_item(self.course, self.user.id) # Change course pacing to self paced
self.assertTrue(self.course.self_paced) course.self_paced = True
self.store.update_item(course, self.user.id)
# Check that in self paced course content has live state now self.assertTrue(course.self_paced)
xblock_info = self._get_xblock_info(chapter.location)
self._verify_visibility_state(xblock_info, VisibilityState.live) # Check that in self paced course content has live state now
xblock_info = self._get_xblock_info(chapter.location)
self._verify_visibility_state(xblock_info, VisibilityState.live)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment