Commit 06977c19 by Will Daly

Created new test configuration for MixedModuleStore

parent 594a73d4
import copy import copy
from uuid import uuid4 from uuid import uuid4
from django.test import TestCase from django.test import TestCase
...@@ -8,6 +7,41 @@ import xmodule.modulestore.django ...@@ -8,6 +7,41 @@ import xmodule.modulestore.django
from unittest.util import safe_repr 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): def mongo_store_config(data_dir):
""" """
Defines default module store using MongoModuleStore. Defines default module store using MongoModuleStore.
...@@ -27,6 +61,7 @@ def mongo_store_config(data_dir): ...@@ -27,6 +61,7 @@ def mongo_store_config(data_dir):
} }
} }
} }
store['direct'] = store['default'] store['direct'] = store['default']
return store return store
...@@ -45,23 +80,22 @@ def draft_mongo_store_config(data_dir): ...@@ -45,23 +80,22 @@ def draft_mongo_store_config(data_dir):
'render_template': 'mitxmako.shortcuts.render_to_string' 'render_template': 'mitxmako.shortcuts.render_to_string'
} }
return { store = {
'default': { 'default': {
'ENGINE': 'xmodule.modulestore.mongo.draft.DraftModuleStore', 'ENGINE': 'xmodule.modulestore.mongo.draft.DraftModuleStore',
'OPTIONS': modulestore_options 'OPTIONS': modulestore_options
},
'direct': {
'ENGINE': 'xmodule.modulestore.mongo.MongoModuleStore',
'OPTIONS': modulestore_options
} }
} }
store['direct'] = store['default']
return store
def xml_store_config(data_dir): def xml_store_config(data_dir):
""" """
Defines default module store using XMLModuleStore. Defines default module store using XMLModuleStore.
""" """
return { store = {
'default': { 'default': {
'ENGINE': 'xmodule.modulestore.xml.XMLModuleStore', 'ENGINE': 'xmodule.modulestore.xml.XMLModuleStore',
'OPTIONS': { 'OPTIONS': {
...@@ -71,6 +105,9 @@ def xml_store_config(data_dir): ...@@ -71,6 +105,9 @@ def xml_store_config(data_dir):
} }
} }
store['direct'] = store['default']
return store
class ModuleStoreTestCase(TestCase): class ModuleStoreTestCase(TestCase):
""" Subclass for any test case that uses the mongodb """ Subclass for any test case that uses the mongodb
......
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