Commit 48a5b954 by Hassan Committed by Hassan Javeed

Use CourseOverview for dump_course_ids

parent 04cadf79
...@@ -6,6 +6,7 @@ from textwrap import dedent ...@@ -6,6 +6,7 @@ from textwrap import dedent
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from xmodule.modulestore.django import modulestore from xmodule.modulestore.django import modulestore
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
class Command(BaseCommand): class Command(BaseCommand):
...@@ -24,17 +25,6 @@ class Command(BaseCommand): ...@@ -24,17 +25,6 @@ class Command(BaseCommand):
) )
def handle(self, *args, **options): def handle(self, *args, **options):
store = modulestore() output = u'\n'.join(unicode(course_overview.id) for course_overview in CourseOverview.get_all_courses()) + '\n'
name = options['modulestore']
if name != 'default':
# since a store type is given, get that specific store
if hasattr(store, '_get_modulestore_by_type'):
store = store._get_modulestore_by_type(name)
if store.get_modulestore_type() != name:
raise CommandError("Modulestore {} not found".format(name))
if store is None:
raise CommandError("Unknown modulestore {}".format(name))
output = u'\n'.join(unicode(course.id) for course in store.get_courses()) + '\n'
return output return output
...@@ -25,14 +25,6 @@ from xmodule.modulestore.xml_importer import import_course_from_xml ...@@ -25,14 +25,6 @@ from xmodule.modulestore.xml_importer import import_course_from_xml
DATA_DIR = settings.COMMON_TEST_DATA_ROOT DATA_DIR = settings.COMMON_TEST_DATA_ROOT
XML_COURSE_DIRS = ['toy', 'simple'] XML_COURSE_DIRS = ['toy', 'simple']
MAPPINGS = {
'edX/toy/2012_Fall': 'xml',
'edX/simple/2012_Fall': 'xml',
}
TEST_DATA_MIXED_XML_MODULESTORE = mixed_store_config(
DATA_DIR, MAPPINGS, include_xml=True, xml_source_dirs=XML_COURSE_DIRS,
)
@attr('shard_1') @attr('shard_1')
...@@ -59,6 +51,7 @@ class CommandsTestBase(ModuleStoreTestCase): ...@@ -59,6 +51,7 @@ class CommandsTestBase(ModuleStoreTestCase):
# Add a course with a unicode name. # Add a course with a unicode name.
unique_org = factory.Sequence(lambda n: u'ëḋẌ.%d' % n) unique_org = factory.Sequence(lambda n: u'ëḋẌ.%d' % n)
CourseFactory.create( CourseFactory.create(
emit_signals=True,
org=unique_org, org=unique_org,
course=u'śíḿṕĺé', course=u'śíḿṕĺé',
display_name=u'2012_Fáĺĺ', display_name=u'2012_Fáĺĺ',
...@@ -82,10 +75,8 @@ class CommandsTestBase(ModuleStoreTestCase): ...@@ -82,10 +75,8 @@ class CommandsTestBase(ModuleStoreTestCase):
return out.read() return out.read()
def test_dump_course_ids(self): def test_dump_course_ids(self):
kwargs = {'modulestore': 'default'} output = self.call_command('dump_course_ids')
output = self.call_command('dump_course_ids', **kwargs)
dumped_courses = output.decode('utf-8').strip().split('\n') dumped_courses = output.decode('utf-8').strip().split('\n')
course_ids = {unicode(course_id) for course_id in self.loaded_courses} course_ids = {unicode(course_id) for course_id in self.loaded_courses}
dumped_ids = set(dumped_courses) dumped_ids = set(dumped_courses)
self.assertEqual(course_ids, dumped_ids) self.assertEqual(course_ids, dumped_ids)
...@@ -205,15 +196,6 @@ class CommandsTestBase(ModuleStoreTestCase): ...@@ -205,15 +196,6 @@ class CommandsTestBase(ModuleStoreTestCase):
assert_in('edX-simple-2012_Fall/sequential/Lecture_2.xml', names) assert_in('edX-simple-2012_Fall/sequential/Lecture_2.xml', names)
class CommandsXMLTestCase(CommandsTestBase):
"""
Test case for management commands with the xml modulestore present.
"""
MODULESTORE = TEST_DATA_MIXED_XML_MODULESTORE
__test__ = True
class CommandsMongoTestCase(CommandsTestBase): class CommandsMongoTestCase(CommandsTestBase):
""" """
Test case for management commands using the mixed mongo modulestore with old mongo as the default. Test case for management commands using the mixed mongo modulestore with old mongo as the default.
......
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