Merge pull request #6111 from edx/zoldak/modulestore-test-config

Unit test speed improvements
This commit is contained in:
Jesse Zoldak
2014-12-12 10:53:24 -05:00
3 changed files with 26 additions and 7 deletions

View File

@@ -7,6 +7,8 @@ import pytz
from tempfile import mkdtemp
from uuid import uuid4
from mock import patch
from django.conf import settings
from django.contrib.auth.models import User
from django.test import TestCase
@@ -276,10 +278,14 @@ class ModuleStoreTestCase(TestCase):
return updated_course
@staticmethod
def drop_mongo_collections():
@patch('xmodule.modulestore.django.create_modulestore_instance')
def drop_mongo_collections(mock_create):
"""
If using a Mongo-backed modulestore & contentstore, drop the collections.
"""
# Do not create the modulestore if it does not exist.
mock_create.return_value = None
module_store = modulestore()
if hasattr(module_store, '_drop_database'):
module_store._drop_database() # pylint: disable=protected-access
@@ -302,7 +308,6 @@ class ModuleStoreTestCase(TestCase):
"""
Flush the ModuleStore.
"""
# Flush the Mongo modulestore
self.drop_mongo_collections()