Merge pull request #7096 from edx/jeskew/PLAT_454_import_500_error

PLAT-454: Fix import error when exported course edited.
This commit is contained in:
Waqas Khalid
2015-03-02 19:01:51 +05:00
24 changed files with 306 additions and 8 deletions

View File

@@ -52,6 +52,7 @@ from course_action_state.models import CourseRerunState, CourseRerunUIStateManag
from course_action_state.managers import CourseActionStateItemNotFoundError
from xmodule.contentstore.content import StaticContent
from xmodule.modulestore.django import modulestore
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
@@ -387,6 +388,32 @@ class ImportRequiredTestCases(ContentStoreTestCase):
shutil.rmtree(root_dir)
def test_import_after_renaming_xml_data(self):
"""
Test that import works fine on split mongo after renaming the blocks url.
"""
split_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split) # pylint: disable=W0212
import_from_xml(
split_store, self.user.id, TEST_DATA_DIR,
['course_before_rename'],
create_course_if_not_present=True
)
course_after_rename = import_from_xml(
split_store, self.user.id, TEST_DATA_DIR,
['course_after_rename'],
create_course_if_not_present=True
)
all_items = split_store.get_items(course_after_rename[0].id, qualifiers={'category': 'chapter'})
renamed_chapter = [item for item in all_items if item.location.block_id == 'renamed_chapter'][0]
self.assertIsNotNone(renamed_chapter.published_on)
self.assertIsNotNone(renamed_chapter.parent)
self.assertTrue(renamed_chapter.location in course_after_rename[0].children)
original_chapter = [item for item in all_items
if item.location.block_id == 'b9870b9af59841a49e6e02765d0e3bbf'][0]
self.assertIsNone(original_chapter.published_on)
self.assertIsNone(original_chapter.parent)
self.assertFalse(original_chapter.location in course_after_rename[0].children)
def test_empty_data_roundtrip(self):
"""
Test that an empty `data` field is preserved through