Merge pull request #9778 from edx/adam/patch-rc-with-fix-to-fix-not-found
Adam/patch rc with fix to fix not found
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
"""
|
||||
Tests for the fix_not_found management command
|
||||
"""
|
||||
|
||||
from django.core.management import call_command
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
|
||||
|
||||
class TestFixNotFound(ModuleStoreTestCase):
|
||||
"""
|
||||
Tests for the fix_not_found management command
|
||||
"""
|
||||
def test_fix_not_found_non_split(self):
|
||||
"""
|
||||
The management command doesn't work on non split courses
|
||||
"""
|
||||
course = CourseFactory(default_store=ModuleStoreEnum.Type.mongo)
|
||||
with self.assertRaises(SystemExit):
|
||||
call_command("fix_not_found", unicode(course.id))
|
||||
|
||||
def test_fix_not_found(self):
|
||||
course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split)
|
||||
ItemFactory.create(category='chapter', parent_location=course.location)
|
||||
|
||||
# get course again in order to update its children list
|
||||
course = self.store.get_course(course.id)
|
||||
|
||||
# create a dangling usage key that we'll add to the course's children list
|
||||
dangling_pointer = course.id.make_usage_key('chapter', 'DanglingPointer')
|
||||
|
||||
course.children.append(dangling_pointer)
|
||||
self.store.update_item(course, self.user.id)
|
||||
|
||||
# the course block should now point to two children, one of which
|
||||
# doesn't actually exist
|
||||
self.assertEqual(len(course.children), 2)
|
||||
self.assertIn(dangling_pointer, course.children)
|
||||
|
||||
call_command("fix_not_found", unicode(course.id))
|
||||
|
||||
# make sure the dangling pointer was removed from
|
||||
# the course block's children
|
||||
course = self.store.get_course(course.id)
|
||||
self.assertEqual(len(course.children), 1)
|
||||
self.assertNotIn(dangling_pointer, course.children)
|
||||
@@ -312,7 +312,7 @@ class SplitBulkWriteMixin(BulkOperationsMixin):
|
||||
if bulk_write_record.active:
|
||||
bulk_write_record.index = updated_index_entry
|
||||
else:
|
||||
self.db_connection.update_course_index(updated_index_entry, course_key)
|
||||
self.db_connection.update_course_index(updated_index_entry, course_context=course_key)
|
||||
|
||||
def get_structure(self, course_key, version_guid):
|
||||
bulk_write_record = self._get_bulk_ops_record(course_key)
|
||||
|
||||
Reference in New Issue
Block a user