Address code coverage and quality.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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'])
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user