Support running test with split modulestore as the default.
With split, "name" returns "course" instead of the run name.
This commit is contained in:
@@ -113,7 +113,7 @@ def export_to_xml(modulestore, contentstore, course_key, root_dir, course_dir):
|
||||
export_extra_content(export_fs, modulestore, course_key, xml_centric_course_key, 'about', 'about', '.html')
|
||||
|
||||
# export the grading policy
|
||||
course_run_policy_dir = policies_dir.makeopendir(course.location.name)
|
||||
course_run_policy_dir = policies_dir.makeopendir(course.location.run)
|
||||
with course_run_policy_dir.open('grading_policy.json', 'w') as grading_policy:
|
||||
grading_policy.write(dumps(course.grading_policy, cls=EdxJSONEncoder, sort_keys=True, indent=4))
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.modulestore.xml_importer import import_from_xml
|
||||
|
||||
DATA_DIR = settings.COMMON_TEST_DATA_ROOT
|
||||
TEST_COURSE_ID = 'edX/simple/2012_Fall'
|
||||
XML_COURSE_DIRS = ['toy', 'simple', 'open_ended']
|
||||
MAPPINGS = {
|
||||
'edX/toy/2012_Fall': 'xml',
|
||||
@@ -47,6 +46,7 @@ class CommandsTestBase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(CommandsTestBase, self).setUp()
|
||||
self.test_course_key = modulestore().make_course_key("edX", "simple", "2012_Fall")
|
||||
self.loaded_courses = self.load_courses()
|
||||
|
||||
def load_courses(self):
|
||||
@@ -56,15 +56,19 @@ class CommandsTestBase(TestCase):
|
||||
# Add a course with a unicode name, if the modulestore
|
||||
# supports adding modules.
|
||||
if hasattr(store, 'create_xmodule'):
|
||||
CourseFactory.create(org=u'ëḋẌ',
|
||||
course=u'śíḿṕĺé',
|
||||
display_name=u'2012_Fáĺĺ',
|
||||
modulestore=store)
|
||||
CourseFactory.create(
|
||||
org=u'ëḋẌ',
|
||||
course=u'śíḿṕĺé',
|
||||
display_name=u'2012_Fáĺĺ',
|
||||
modulestore=store
|
||||
)
|
||||
|
||||
courses = store.get_courses()
|
||||
# NOTE: if xml store owns these, it won't import them into mongo
|
||||
if SlashSeparatedCourseKey.from_deprecated_string(TEST_COURSE_ID) not in [c.id for c in courses]:
|
||||
import_from_xml(store, ModuleStoreEnum.UserID.mgmt_command, DATA_DIR, XML_COURSE_DIRS)
|
||||
if self.test_course_key not in [c.id for c in courses]:
|
||||
import_from_xml(
|
||||
store, ModuleStoreEnum.UserID.mgmt_command, DATA_DIR, XML_COURSE_DIRS, create_course_if_not_present=True
|
||||
)
|
||||
|
||||
return [course.id for course in store.get_courses()]
|
||||
|
||||
@@ -80,12 +84,12 @@ class CommandsTestBase(TestCase):
|
||||
output = self.call_command('dump_course_ids', **kwargs)
|
||||
dumped_courses = output.decode('utf-8').strip().split('\n')
|
||||
|
||||
course_ids = {course_id.to_deprecated_string() for course_id in self.loaded_courses}
|
||||
course_ids = {unicode(course_id) for course_id in self.loaded_courses}
|
||||
dumped_ids = set(dumped_courses)
|
||||
self.assertEqual(course_ids, dumped_ids)
|
||||
|
||||
def test_correct_course_structure_metadata(self):
|
||||
course_id = 'edX/open_ended/2012_Fall'
|
||||
course_id = unicode(modulestore().make_course_key('edX', 'open_ended', '2012_Fall'))
|
||||
args = [course_id]
|
||||
kwargs = {'modulestore': 'default'}
|
||||
|
||||
@@ -98,7 +102,7 @@ class CommandsTestBase(TestCase):
|
||||
self.assertGreater(len(dump.values()), 0)
|
||||
|
||||
def test_dump_course_structure(self):
|
||||
args = [TEST_COURSE_ID]
|
||||
args = [unicode(self.test_course_key)]
|
||||
kwargs = {'modulestore': 'default'}
|
||||
output = self.call_command('dump_course_structure', *args, **kwargs)
|
||||
|
||||
@@ -113,8 +117,8 @@ class CommandsTestBase(TestCase):
|
||||
self.assertNotIn('inherited_metadata', element)
|
||||
|
||||
# Check a few elements in the course dump
|
||||
test_course_key = SlashSeparatedCourseKey.from_deprecated_string(TEST_COURSE_ID)
|
||||
parent_id = test_course_key.make_usage_key('chapter', 'Overview').to_deprecated_string()
|
||||
test_course_key = self.test_course_key
|
||||
parent_id = unicode(test_course_key.make_usage_key('chapter', 'Overview'))
|
||||
self.assertEqual(dump[parent_id]['category'], 'chapter')
|
||||
self.assertEqual(len(dump[parent_id]['children']), 3)
|
||||
|
||||
@@ -132,7 +136,7 @@ class CommandsTestBase(TestCase):
|
||||
self.assertEqual(len(dump), 16)
|
||||
|
||||
def test_dump_inherited_course_structure(self):
|
||||
args = [TEST_COURSE_ID]
|
||||
args = [unicode(self.test_course_key)]
|
||||
kwargs = {'modulestore': 'default', 'inherited': True}
|
||||
output = self.call_command('dump_course_structure', *args, **kwargs)
|
||||
dump = json.loads(output)
|
||||
@@ -148,7 +152,7 @@ class CommandsTestBase(TestCase):
|
||||
self.assertNotIn('due', element['inherited_metadata'])
|
||||
|
||||
def test_dump_inherited_course_structure_with_defaults(self):
|
||||
args = [TEST_COURSE_ID]
|
||||
args = [unicode(self.test_course_key)]
|
||||
kwargs = {'modulestore': 'default', 'inherited': True, 'inherited_defaults': True}
|
||||
output = self.call_command('dump_course_structure', *args, **kwargs)
|
||||
dump = json.loads(output)
|
||||
@@ -180,7 +184,7 @@ class CommandsTestBase(TestCase):
|
||||
self.check_export_file(tar_file)
|
||||
|
||||
def run_export_course(self, filename): # pylint: disable=missing-docstring
|
||||
args = [TEST_COURSE_ID, filename]
|
||||
args = [unicode(self.test_course_key), filename]
|
||||
kwargs = {'modulestore': 'default'}
|
||||
return self.call_command('export_course', *args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user