From 06977c198ebf3cbd3cc8d24cbc243ace635c5d01 Mon Sep 17 00:00:00 2001 From: Will Daly Date: Mon, 19 Aug 2013 08:47:53 -0400 Subject: [PATCH] Created new test configuration for MixedModuleStore --- .../xmodule/modulestore/tests/django_utils.py | 51 ++++++++++++++++--- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py index 4f998d57fb..8b8d61c85a 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/django_utils.py @@ -1,4 +1,3 @@ - import copy from uuid import uuid4 from django.test import TestCase @@ -8,6 +7,41 @@ import xmodule.modulestore.django from unittest.util import safe_repr +def mixed_store_config(data_dir, mappings): + """ + Return a `MixedModuleStore` configuration, which provides + access to both Mongo- and XML-backed courses. + + `data_dir` is the directory from which to load XML-backed courses. + `mappings` is a dictionary mapping course IDs to modulestores, for example: + + { + 'MITx/2.01x/2013_Spring': 'xml', + 'edx/999/2013_Spring': 'default' + } + + where 'xml' and 'default' are the two options provided by this configuration, + mapping (respectively) to XML-backed and Mongo-backed modulestores.. + """ + mongo_config = mongo_store_config(data_dir) + xml_config = xml_store_config(data_dir) + + store = { + 'default': { + 'ENGINE': 'xmodule.modulestore.mixed.MixedModuleStore', + 'OPTIONS': { + 'mappings': mappings, + 'stores': { + 'default': mongo_config['default'], + 'xml': xml_config['default'] + } + } + } + } + store['direct'] = store['default'] + return store + + def mongo_store_config(data_dir): """ Defines default module store using MongoModuleStore. @@ -27,6 +61,7 @@ def mongo_store_config(data_dir): } } } + store['direct'] = store['default'] return store @@ -45,23 +80,22 @@ def draft_mongo_store_config(data_dir): 'render_template': 'mitxmako.shortcuts.render_to_string' } - return { + store = { 'default': { 'ENGINE': 'xmodule.modulestore.mongo.draft.DraftModuleStore', 'OPTIONS': modulestore_options - }, - 'direct': { - 'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore', - 'OPTIONS': modulestore_options } } + store['direct'] = store['default'] + return store + def xml_store_config(data_dir): """ Defines default module store using XMLModuleStore. """ - return { + store = { 'default': { 'ENGINE': 'xmodule.modulestore.xml.XMLModuleStore', 'OPTIONS': { @@ -71,6 +105,9 @@ def xml_store_config(data_dir): } } + store['direct'] = store['default'] + return store + class ModuleStoreTestCase(TestCase): """ Subclass for any test case that uses the mongodb