diff --git a/cms/djangoapps/contentstore/tests/test_import.py b/cms/djangoapps/contentstore/tests/test_import.py index 5d063ce3dd..71db964448 100644 --- a/cms/djangoapps/contentstore/tests/test_import.py +++ b/cms/djangoapps/contentstore/tests/test_import.py @@ -14,7 +14,8 @@ 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.tests.factories import check_exact_number_of_calls, check_number_of_calls +from xmodule.modulestore.exceptions import DuplicateCourseError +from xmodule.modulestore.tests.factories import check_exact_number_of_calls, check_number_of_calls, CourseFactory from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation from xmodule.modulestore.xml_importer import import_from_xml from xmodule.exceptions import NotFoundError diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py index d9b501f7bd..0dc859a796 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split_draft.py @@ -297,4 +297,3 @@ class DraftVersioningModuleStore(ModuleStoreDraftAndPublished, SplitMongoModuleS Return the version of the given database representation of a block. """ return block['edit_info'].get('source_version', block['edit_info']['update_version']) - diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py index 4af5fb5cd9..521615e0f9 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py @@ -544,6 +544,13 @@ class TestMixedModuleStore(unittest.TestCase): self.assertIn(self.course_locations[self.XML_COURSEID1], course_ids) self.assertIn(self.course_locations[self.XML_COURSEID2], course_ids) + with self.store.branch_setting(ModuleStoreEnum.Branch.draft_preferred): + draft_courses = self.store.get_courses(remove_branch=True) + with self.store.branch_setting(ModuleStoreEnum.Branch.published_only): + published_courses = self.store.get_courses(remove_branch=True) + self.assertEquals([c.id for c in draft_courses], [c.id for c in published_courses]) + + def test_xml_get_courses(self): """ Test that the xml modulestore only loaded the courses from the maps. @@ -1229,7 +1236,7 @@ class TestMixedModuleStore(unittest.TestCase): with self.store.default_store(default_ms): self.verify_default_store(default_ms) - def test_nested_default_store(self): + def test_default_store_nested(self): """ Test the default store context manager, nested within one another """ @@ -1245,6 +1252,17 @@ class TestMixedModuleStore(unittest.TestCase): self.verify_default_store(ModuleStoreEnum.Type.split) self.verify_default_store(ModuleStoreEnum.Type.mongo) + def test_default_store_fake(self): + """ + Test the default store context manager, asking for a fake store + """ + # initialize the mixed modulestore + self._initialize_mixed() + + fake_store = "fake" + with self.assertRaisesRegexp(Exception, "Cannot find store of type {}".format(fake_store)): + with self.store.default_store(fake_store): + pass # pragma: no cover #============================================================================================================= # General utils for not using django settings diff --git a/common/lib/xmodule/xmodule/modulestore/xml_importer.py b/common/lib/xmodule/xmodule/modulestore/xml_importer.py index 66a3bf4dc0..f7bdd97091 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml_importer.py +++ b/common/lib/xmodule/xmodule/modulestore/xml_importer.py @@ -176,6 +176,7 @@ def import_from_xml( store.create_course(dest_course_id.org, dest_course_id.course, dest_course_id.run, user_id) except DuplicateCourseError: # course w/ same org and course exists + # The Mongo modulestore checks *with* the run in has_course, but not in create_course. log.debug( "Skipping import of course with id, {0}," "since it collides with an existing one".format(dest_course_id)