def setUp(self): """ Set up module store testing capabilities and initialize test courses. """ super(CourseMetadataUtilsTestCase, self).setUp() mongo_builder = MongoModulestoreBuilder() split_builder = VersioningModulestoreBuilder() mixed_builder = MixedModulestoreBuilder([('mongo', mongo_builder), ('split', split_builder)]) with mixed_builder.build_without_contentstore() as (__, mixed_store): with mixed_store.default_store('mongo'): self.demo_course = mixed_store.create_course( org="edX", course="DemoX.1", run="Fall_2014", user_id=-3, # -3 refers to a "testing user" fields={ "start": _LAST_MONTH, "end": _LAST_WEEK } ) with mixed_store.default_store('split'): self.html_course = mixed_store.create_course( org="UniversityX", course="CS-203", run="Y2096", user_id=-3, # -3 refers to a "testing user" fields={ "start": _NEXT_WEEK, "display_name": "Intro to <html>" } )
from shutil import rmtree from unittest import TestCase, skip import ddt from django.test import TestCase from xmodule.modulestore.xml_importer import import_course_from_xml from xmodule.modulestore.xml_exporter import export_course_to_xml from xmodule.modulestore.tests.factories import check_mongo_calls from xmodule.modulestore.tests.utils import ( MixedModulestoreBuilder, VersioningModulestoreBuilder, MongoModulestoreBuilder, TEST_DATA_DIR, MemoryCache, ) MIXED_OLD_MONGO_MODULESTORE_BUILDER = MixedModulestoreBuilder([('draft', MongoModulestoreBuilder())]) MIXED_SPLIT_MODULESTORE_BUILDER = MixedModulestoreBuilder([('split', VersioningModulestoreBuilder())]) @ddt.ddt @skip("Fix call counts below - sometimes the counts are off by 1.") class CountMongoCallsXMLRoundtrip(TestCase): """ This class exists to test XML import and export to/from Split. """ shard = 2 def setUp(self): super(CountMongoCallsXMLRoundtrip, self).setUp() self.export_dir = mkdtemp() self.addCleanup(rmtree, self.export_dir, ignore_errors=True)
import ddt from django.test import TestCase # lint-amnesty, pylint: disable=reimported from xmodule.modulestore.tests.factories import check_mongo_calls from xmodule.modulestore.tests.utils import (TEST_DATA_DIR, MemoryCache, MixedModulestoreBuilder, MongoModulestoreBuilder, VersioningModulestoreBuilder) from xmodule.modulestore.xml_exporter import export_course_to_xml from xmodule.modulestore.xml_importer import import_course_from_xml MIXED_OLD_MONGO_MODULESTORE_BUILDER = MixedModulestoreBuilder([ ('draft', MongoModulestoreBuilder()) ]) MIXED_SPLIT_MODULESTORE_BUILDER = MixedModulestoreBuilder([ ('split', VersioningModulestoreBuilder()) ]) @ddt.ddt @skip("Fix call counts below - sometimes the counts are off by 1.") class CountMongoCallsXMLRoundtrip(TestCase): """ This class exists to test XML import and export to/from Split. """ def setUp(self): super().setUp() self.export_dir = mkdtemp() self.addCleanup(rmtree, self.export_dir, ignore_errors=True) @ddt.data(