Merge pull request #6752 from cpennington/modulestore-test-case-cleanup
Clean up ModuleStoreTestCase
This commit is contained in:
@@ -22,6 +22,8 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Common setup. """
|
||||
super(ExportAllCourses, self).setUp()
|
||||
|
||||
self.content_store = contentstore()
|
||||
self.module_store = modulestore()
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ class TestArgParsing(unittest.TestCase):
|
||||
Tests for parsing arguments for the `create_course` management command
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestArgParsing, self).setUp()
|
||||
|
||||
self.command = Command()
|
||||
|
||||
def test_no_args(self):
|
||||
|
||||
@@ -18,6 +18,7 @@ class ExportAllCourses(ModuleStoreTestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Common setup. """
|
||||
super(ExportAllCourses, self).setUp()
|
||||
self.store = modulestore()._get_modulestore_by_type(ModuleStoreEnum.Type.mongo)
|
||||
self.temp_dir = mkdtemp()
|
||||
self.first_course = CourseFactory.create(org="test", course="course1", display_name="run1")
|
||||
|
||||
@@ -16,6 +16,8 @@ class ConvertExportFormat(TestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Common setup. """
|
||||
super(ConvertExportFormat, self).setUp()
|
||||
|
||||
self.temp_dir = mkdtemp()
|
||||
self.data_dir = path(__file__).realpath().parent / 'data'
|
||||
self.version0 = self.data_dir / "Version0_drafts.tar.gz"
|
||||
|
||||
@@ -1747,6 +1747,7 @@ class EntryPageTestCase(TestCase):
|
||||
Tests entry pages that aren't specific to a course.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(EntryPageTestCase, self).setUp()
|
||||
self.client = AjaxEnabledTestClient()
|
||||
|
||||
def _test_page(self, page, status_code=200):
|
||||
|
||||
@@ -20,6 +20,7 @@ class TemplateTests(unittest.TestCase):
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TemplateTests, self).setUp()
|
||||
clear_existing_modulestores() # redundant w/ cleanup but someone was getting errors
|
||||
self.addCleanup(self._drop_mongo_collections)
|
||||
self.addCleanup(clear_existing_modulestores)
|
||||
|
||||
@@ -19,6 +19,8 @@ class InternationalizationTest(ModuleStoreTestCase):
|
||||
will be cleared out before each test case execution and deleted
|
||||
afterwards.
|
||||
"""
|
||||
super(InternationalizationTest, self).setUp(create_user=False)
|
||||
|
||||
self.uname = 'testuser'
|
||||
self.email = 'test+courses@edx.org'
|
||||
self.password = 'foo'
|
||||
|
||||
@@ -28,6 +28,8 @@ TEST_DATA_CONTENTSTORE['DOC_STORE_CONFIG']['db'] = 'test_xcontent_%s' % uuid4().
|
||||
class TestGenerateSubs(unittest.TestCase):
|
||||
"""Tests for `generate_subs` function."""
|
||||
def setUp(self):
|
||||
super(TestGenerateSubs, self).setUp()
|
||||
|
||||
self.source_subs = {
|
||||
'start': [100, 200, 240, 390, 1000],
|
||||
'end': [200, 240, 380, 1000, 1500],
|
||||
@@ -93,6 +95,7 @@ class TestSaveSubsToStore(ModuleStoreTestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
||||
super(TestSaveSubsToStore, self).setUp()
|
||||
self.course = CourseFactory.create(
|
||||
org=self.org, number=self.number, display_name=self.display_name)
|
||||
|
||||
@@ -183,6 +186,7 @@ class TestDownloadYoutubeSubs(ModuleStoreTestCase):
|
||||
self.clear_sub_content(subs_id)
|
||||
|
||||
def setUp(self):
|
||||
super(TestDownloadYoutubeSubs, self).setUp()
|
||||
self.course = CourseFactory.create(
|
||||
org=self.org, number=self.number, display_name=self.display_name)
|
||||
|
||||
@@ -477,6 +481,7 @@ class TestTranscript(unittest.TestCase):
|
||||
Tests for Transcript class e.g. different transcript conversions.
|
||||
"""
|
||||
def setUp(self):
|
||||
super(TestTranscript, self).setUp()
|
||||
|
||||
self.srt_transcript = textwrap.dedent("""\
|
||||
0
|
||||
|
||||
@@ -12,6 +12,7 @@ from contentstore import utils
|
||||
from contentstore.tests.utils import CourseTestCase
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from opaque_keys.edx.locations import SlashSeparatedCourseKey
|
||||
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -164,7 +165,7 @@ class ExtraPanelTabTestCase(TestCase):
|
||||
self.assertEqual(actual_tabs, expected_tabs)
|
||||
|
||||
|
||||
class CourseImageTestCase(TestCase):
|
||||
class CourseImageTestCase(ModuleStoreTestCase):
|
||||
"""Tests for course image URLs."""
|
||||
|
||||
def test_get_image_url(self):
|
||||
@@ -196,6 +197,8 @@ class XBlockVisibilityTestCase(TestCase):
|
||||
"""Tests for xblock visibility for students."""
|
||||
|
||||
def setUp(self):
|
||||
super(XBlockVisibilityTestCase, self).setUp()
|
||||
|
||||
self.dummy_user = ModuleStoreEnum.UserID.test
|
||||
self.past = datetime(1970, 1, 1)
|
||||
self.future = datetime.now(UTC) + timedelta(days=1)
|
||||
|
||||
@@ -88,6 +88,8 @@ class AuthTestCase(ContentStoreTestCase):
|
||||
"""Check that various permissions-related things work"""
|
||||
|
||||
def setUp(self):
|
||||
super(AuthTestCase, self).setUp(create_user=False)
|
||||
|
||||
self.email = 'a@b.com'
|
||||
self.pw = 'xyz'
|
||||
self.username = 'testuser'
|
||||
|
||||
@@ -67,7 +67,6 @@ class AjaxEnabledTestClient(Client):
|
||||
return self.get(path, data or {}, follow, HTTP_ACCEPT="application/json", **extra)
|
||||
|
||||
|
||||
@override_settings(MODULESTORE=TEST_DATA_MOCK_MODULESTORE)
|
||||
class CourseTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
Base class for Studio tests that require a logged in user and a course.
|
||||
@@ -81,6 +80,7 @@ class CourseTestCase(ModuleStoreTestCase):
|
||||
will be cleared out before each test case execution and deleted
|
||||
afterwards.
|
||||
"""
|
||||
|
||||
self.user_password = super(CourseTestCase, self).setUp()
|
||||
|
||||
self.client = AjaxEnabledTestClient()
|
||||
|
||||
@@ -17,6 +17,8 @@ class RolesTest(TestCase):
|
||||
"""
|
||||
def setUp(self):
|
||||
""" Test case setup """
|
||||
super(RolesTest, self).setUp()
|
||||
|
||||
self.global_admin = AdminFactory()
|
||||
self.instructor = User.objects.create_user('testinstructor', 'testinstructor+courses@edx.org', 'foo')
|
||||
self.staff = User.objects.create_user('teststaff', 'teststaff+courses@edx.org', 'foo')
|
||||
|
||||
@@ -1188,6 +1188,8 @@ class TestEditSplitModule(ItemTest):
|
||||
@ddt.ddt
|
||||
class TestComponentHandler(TestCase):
|
||||
def setUp(self):
|
||||
super(TestComponentHandler, self).setUp()
|
||||
|
||||
self.request_factory = RequestFactory()
|
||||
|
||||
patcher = patch('contentstore.views.component.modulestore')
|
||||
|
||||
@@ -22,7 +22,7 @@ from cms.djangoapps.xblock_config.models import StudioConfig
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
class GetPreviewHtmlTestCase(TestCase):
|
||||
class GetPreviewHtmlTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
Tests for get_preview_fragment.
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ from contentstore.tests.utils import CourseTestCase
|
||||
from django.test import TestCase
|
||||
from xmodule.x_module import STUDENT_VIEW
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
|
||||
from xmodule.tabs import CourseTabList, WikiTab
|
||||
from contentstore.utils import reverse_course_url
|
||||
from xmodule.modulestore.django import modulestore
|
||||
@@ -192,7 +193,7 @@ class TabsPageTests(CourseTestCase):
|
||||
self.assertIn('<span data-tooltip="Drag to reorder" class="drag-handle action"></span>', html)
|
||||
|
||||
|
||||
class PrimitiveTabEdit(TestCase):
|
||||
class PrimitiveTabEdit(ModuleStoreTestCase):
|
||||
"""Tests for the primitive tab edit data manipulations"""
|
||||
|
||||
def test_delete(self):
|
||||
|
||||
@@ -292,6 +292,8 @@ class TextbookValidationTestCase(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
"Set some useful content for tests"
|
||||
super(TextbookValidationTestCase, self).setUp()
|
||||
|
||||
self.tb1 = {
|
||||
"tab_title": "Hi, mom!",
|
||||
"url": "/mom.pdf"
|
||||
|
||||
Reference in New Issue
Block a user