Merge pull request #4370 from edx/nimisha/split-drop-database-2952
Implement close_connections and drop_database on modulestores.
This commit is contained in:
@@ -56,7 +56,7 @@ class TestMigrateToSplit(ModuleStoreTestCase):
|
||||
password = 'foo'
|
||||
self.user = User.objects.create_user(uname, email, password)
|
||||
self.course = CourseFactory()
|
||||
self.addCleanup(ModuleStoreTestCase.drop_mongo_collections, ModuleStoreEnum.Type.split)
|
||||
self.addCleanup(ModuleStoreTestCase.drop_mongo_collections)
|
||||
self.addCleanup(clear_existing_modulestores)
|
||||
|
||||
def test_user_email(self):
|
||||
|
||||
@@ -22,7 +22,7 @@ from django.test.utils import override_settings
|
||||
from contentstore.tests.utils import parse_json, AjaxEnabledTestClient, CourseTestCase
|
||||
from contentstore.views.component import ADVANCED_COMPONENT_TYPES
|
||||
|
||||
from xmodule.contentstore.django import contentstore, _CONTENTSTORE
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xmodule.contentstore.utils import restore_asset_from_trashcan, empty_asset_trashcan
|
||||
from xmodule.exceptions import NotFoundError, InvalidVersionError
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
@@ -74,10 +74,6 @@ class ContentStoreToyCourseTest(ContentStoreTestCase):
|
||||
Tests that rely on the toy courses.
|
||||
TODO: refactor using CourseFactory so they do not.
|
||||
"""
|
||||
def tearDown(self):
|
||||
contentstore().drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
def check_components_on_page(self, component_types, expected_types):
|
||||
"""
|
||||
Ensure that the right types end up on the page.
|
||||
@@ -947,10 +943,6 @@ class ContentStoreTest(ContentStoreTestCase):
|
||||
'run': '2013_Spring'
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
contentstore().drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
def assert_created_course(self, number_suffix=None):
|
||||
"""
|
||||
Checks that the course was created properly.
|
||||
|
||||
@@ -20,7 +20,7 @@ class TemplateTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
clear_existing_modulestores() # redundant w/ cleanup but someone was getting errors
|
||||
self.addCleanup(ModuleStoreTestCase.drop_mongo_collections, ModuleStoreEnum.Type.split)
|
||||
self.addCleanup(ModuleStoreTestCase.drop_mongo_collections)
|
||||
self.addCleanup(clear_existing_modulestores)
|
||||
self.split_store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.split)
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ from django.test.utils import override_settings
|
||||
|
||||
from .utils import CourseTestCase
|
||||
import contentstore.git_export_utils as git_export_utils
|
||||
from xmodule.contentstore.django import _CONTENTSTORE
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from contentstore.utils import reverse_course_url
|
||||
|
||||
@@ -35,10 +34,6 @@ class TestExportGit(CourseTestCase):
|
||||
self.course_module = modulestore().get_course(self.course.id)
|
||||
self.test_url = reverse_course_url('export_git', self.course.id)
|
||||
|
||||
def tearDown(self):
|
||||
modulestore().contentstore.drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
def test_giturl_missing(self):
|
||||
"""
|
||||
Test to make sure an appropriate error is displayed
|
||||
|
||||
@@ -9,16 +9,11 @@ from django.test.utils import override_settings
|
||||
from django.conf import settings
|
||||
import copy
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey, AssetLocation
|
||||
from xmodule.modulestore.xml_importer import import_from_xml
|
||||
from xmodule.contentstore.django import _CONTENTSTORE
|
||||
|
||||
from xmodule.exceptions import NotFoundError
|
||||
from uuid import uuid4
|
||||
|
||||
@@ -38,10 +33,6 @@ class ContentStoreImportTest(ModuleStoreTestCase):
|
||||
self.client = Client()
|
||||
self.client.login(username=self.user.username, password=password)
|
||||
|
||||
def tearDown(self):
|
||||
contentstore().drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
def load_test_import_course(self):
|
||||
'''
|
||||
Load the standard course used to test imports
|
||||
|
||||
@@ -18,7 +18,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
|
||||
from xmodule.contentstore.content import StaticContent
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.exceptions import NotFoundError
|
||||
from xmodule.contentstore.django import contentstore, _CONTENTSTORE
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xmodule.video_module import transcripts_utils
|
||||
|
||||
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
|
||||
@@ -151,8 +151,6 @@ class TestSaveSubsToStore(ModuleStoreTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.clear_subs_content()
|
||||
contentstore().drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
|
||||
@override_settings(CONTENTSTORE=TEST_DATA_CONTENTSTORE)
|
||||
@@ -189,10 +187,6 @@ class TestDownloadYoutubeSubs(ModuleStoreTestCase):
|
||||
self.course = CourseFactory.create(
|
||||
org=self.org, number=self.number, display_name=self.display_name)
|
||||
|
||||
def tearDown(self):
|
||||
contentstore().drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
def test_success_downloading_subs(self):
|
||||
|
||||
response = textwrap.dedent("""<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
@@ -9,20 +9,17 @@ import shutil
|
||||
import tarfile
|
||||
import tempfile
|
||||
from path import path
|
||||
from pymongo import MongoClient
|
||||
from uuid import uuid4
|
||||
|
||||
from django.test.utils import override_settings
|
||||
from django.conf import settings
|
||||
from contentstore.utils import reverse_course_url
|
||||
|
||||
from xmodule.contentstore.django import _CONTENTSTORE
|
||||
from xmodule.modulestore.tests.factories import ItemFactory
|
||||
|
||||
from contentstore.tests.utils import CourseTestCase
|
||||
from student import auth
|
||||
from student.roles import CourseInstructorRole, CourseStaffRole
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
TEST_DATA_CONTENTSTORE = copy.deepcopy(settings.CONTENTSTORE)
|
||||
TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().hex
|
||||
@@ -70,8 +67,6 @@ class ImportTestCase(CourseTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.content_dir)
|
||||
modulestore().contentstore.drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
def test_no_coursexml(self):
|
||||
"""
|
||||
|
||||
@@ -15,7 +15,7 @@ from django.conf import settings
|
||||
from contentstore.tests.utils import CourseTestCase
|
||||
from cache_toolbox.core import del_cached_content
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.contentstore.django import contentstore, _CONTENTSTORE
|
||||
from xmodule.contentstore.django import contentstore
|
||||
from xmodule.contentstore.content import StaticContent
|
||||
from xmodule.exceptions import NotFoundError
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
@@ -80,10 +80,6 @@ class Basetranscripts(CourseTestCase):
|
||||
1.5: item.youtube_id_1_5
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
contentstore().drop_database()
|
||||
_CONTENTSTORE.clear()
|
||||
|
||||
|
||||
class TestUploadtranscripts(Basetranscripts):
|
||||
"""Tests for '/transcripts/upload' url."""
|
||||
|
||||
Reference in New Issue
Block a user