Commit 272dd2aa by Nimisha Asthagiri

Merge pull request #5071 from edx/split/re-import-issue

LMS-11342 Fix Split reimport issue.
parents f591f381 b6590228
......@@ -8,14 +8,14 @@ Tests for import_from_xml using the mongo modulestore.
from django.test.client import Client
from django.test.utils import override_settings
from django.conf import settings
import ddt
import copy
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.contentstore.django import contentstore
from xmodule.modulestore.exceptions import DuplicateCourseError
from xmodule.modulestore.tests.factories import check_exact_number_of_calls, check_number_of_calls, CourseFactory
from xmodule.modulestore.tests.factories import check_exact_number_of_calls, check_number_of_calls
from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation
from xmodule.modulestore.xml_importer import import_from_xml
from xmodule.exceptions import NotFoundError
......@@ -25,6 +25,7 @@ TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex
@ddt.ddt
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
class ContentStoreImportTest(ModuleStoreTestCase):
"""
......@@ -37,7 +38,7 @@ class ContentStoreImportTest(ModuleStoreTestCase):
self.client = Client()
self.client.login(username=self.user.username, password=password)
def load_test_import_course(self):
def load_test_import_course(self, target_course_id=None, create_new_course_if_not_present=False):
'''
Load the standard course used to test imports
(for do_import_static=False behavior).
......@@ -52,6 +53,8 @@ class ContentStoreImportTest(ModuleStoreTestCase):
static_content_store=content_store,
do_import_static=False,
verbose=True,
target_course_id=target_course_id,
create_new_course_if_not_present=create_new_course_if_not_present,
)
course_id = SlashSeparatedCourseKey('edX', 'test_import_course', '2012_Fall')
course = module_store.get_course(course_id)
......@@ -168,6 +171,12 @@ class ContentStoreImportTest(ModuleStoreTestCase):
with check_number_of_calls(store, '_compute_metadata_inheritance_tree', 2):
self.load_test_import_course()
@ddt.data(ModuleStoreEnum.Type.mongo, ModuleStoreEnum.Type.split)
def test_reimport(self, default_ms_type):
with modulestore().default_store(default_ms_type):
__, __, course = self.load_test_import_course(create_new_course_if_not_present=True)
self.load_test_import_course(target_course_id=course.id)
def test_rewrite_reference_list(self):
module_store = modulestore()
target_course_id = SlashSeparatedCourseKey('testX', 'conditional_copy', 'copy_run')
......
......@@ -386,7 +386,7 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS
course_key = self._map_revision_to_branch(course_key) # cast to branch_setting
return self._update_item_from_fields(
user_id, course_key, block_type, block_id, partitioned_fields, None, allow_not_found=True, force=True
)
) or self.get_item(new_usage_key)
def compute_published_info_internal(self, xblock):
"""
......
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