Skip to content
Snippets Groups Projects
Commit b287940d authored by Matthew Piatetsky's avatar Matthew Piatetsky
Browse files

Add management command to export course metadata for all courses

parent b1581882
No related branches found
No related tags found
No related merge requests found
"""
Export course metadata for all courses
"""
from django.core.management.base import BaseCommand
from xmodule.modulestore.django import modulestore
from cms.djangoapps.export_course_metadata.signals import export_course_metadata
class Command(BaseCommand):
"""
Export course metadata for all courses
"""
help = 'Export course metadata for all courses'
def handle(self, *args, **options):
"""
Execute the command
"""
export_course_metadata_for_all_courses()
def export_course_metadata_for_all_courses():
"""
Export course metadata for all courses
"""
module_store = modulestore()
courses = module_store.get_courses()
for course in courses:
export_course_metadata(None, course.id)
"""
Tests for exporting course metadata for all courses.
"""
from unittest.mock import patch
from edx_toggles.toggles.testutils import override_waffle_flag
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from cms.djangoapps.export_course_metadata.toggles import EXPORT_COURSE_METADATA_FLAG
from ..export_course_metadata_for_all_courses import export_course_metadata_for_all_courses
@override_waffle_flag(EXPORT_COURSE_METADATA_FLAG, True)
class ExportAllCourses(ModuleStoreTestCase):
"""
Tests for exporting course metadata for all courses.
"""
def setUp(self):
super().setUp()
CourseFactory.create()
CourseFactory.create()
@patch('cms.djangoapps.export_course_metadata.tasks.course_metadata_export_storage.save')
def test_exporting_all_courses(self, patched_storage):
"""
Test for exporting course metadata for all courses.
"""
export_course_metadata_for_all_courses()
assert len(patched_storage.mock_calls) == 2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment