Enable Block Transformer Registry in tests

This commit is contained in:
Nimisha Asthagiri
2016-06-21 15:36:45 -04:00
parent 85687dcf60
commit f016647fef
8 changed files with 7 additions and 36 deletions

View File

@@ -4,7 +4,6 @@ Tests for Blocks api.py
from django.test.client import RequestFactory
from openedx.core.djangoapps.content.block_structure.tests.helpers import EnableTransformerRegistryMixin
from student.tests.factories import UserFactory
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
@@ -13,7 +12,7 @@ from xmodule.modulestore.tests.factories import SampleCourseFactory
from ..api import get_blocks
class TestGetBlocks(EnableTransformerRegistryMixin, SharedModuleStoreTestCase):
class TestGetBlocks(SharedModuleStoreTestCase):
"""
Tests for the get_blocks function
"""

View File

@@ -7,7 +7,6 @@ from urllib import urlencode
from rest_framework.exceptions import PermissionDenied
from opaque_keys.edx.locator import CourseLocator
from openedx.core.djangoapps.content.block_structure.tests.helpers import EnableTransformerRegistryMixin
from openedx.core.djangoapps.util.test_forms import FormTestMixin
from student.models import CourseEnrollment
from student.tests.factories import UserFactory, CourseEnrollmentFactory
@@ -18,7 +17,7 @@ from ..forms import BlockListGetForm
@ddt.ddt
class TestBlockListGetForm(EnableTransformerRegistryMixin, FormTestMixin, SharedModuleStoreTestCase):
class TestBlockListGetForm(FormTestMixin, SharedModuleStoreTestCase):
"""
Tests for BlockListGetForm
"""

View File

@@ -3,7 +3,6 @@ Tests for Course Blocks serializers
"""
from mock import MagicMock
from openedx.core.djangoapps.content.block_structure.tests.helpers import EnableTransformerRegistryMixin
from openedx.core.lib.block_structure.transformers import BlockStructureTransformers
from student.tests.factories import UserFactory
from xmodule.modulestore import ModuleStoreEnum
@@ -17,7 +16,7 @@ from ..serializers import BlockSerializer, BlockDictSerializer
from .helpers import deserialize_usage_key
class TestBlockSerializerBase(EnableTransformerRegistryMixin, SharedModuleStoreTestCase):
class TestBlockSerializerBase(SharedModuleStoreTestCase):
"""
Base class for testing BlockSerializer and BlockDictSerializer
"""

View File

@@ -8,7 +8,6 @@ from urllib import urlencode
from urlparse import urlunparse
from opaque_keys.edx.locator import CourseLocator
from openedx.core.djangoapps.content.block_structure.tests.helpers import EnableTransformerRegistryMixin
from student.models import CourseEnrollment
from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
@@ -17,7 +16,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory
from .helpers import deserialize_usage_key
class TestBlocksView(EnableTransformerRegistryMixin, SharedModuleStoreTestCase):
class TestBlocksView(SharedModuleStoreTestCase):
"""
Test class for BlocksView
"""

View File

@@ -6,7 +6,6 @@ from mock import Mock
from . import BaseTestXmodule
from course_api.blocks.tests.helpers import deserialize_usage_key
from courseware.module_render import get_module_for_descriptor_internal
from openedx.core.djangoapps.content.block_structure.tests.helpers import EnableTransformerRegistryMixin
from student.tests.factories import UserFactory, CourseEnrollmentFactory
from xmodule.discussion_module import DiscussionModule
from xmodule.modulestore import ModuleStoreEnum
@@ -16,7 +15,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory, ItemFactory
@ddt.ddt
class DiscussionModuleTest(BaseTestXmodule, EnableTransformerRegistryMixin, SharedModuleStoreTestCase):
class DiscussionModuleTest(BaseTestXmodule, SharedModuleStoreTestCase):
"""Logic tests for Discussion Xmodule."""
CATEGORY = "discussion"

View File

@@ -577,11 +577,6 @@ JWT_AUTH.update({
'JWT_AUDIENCE': 'test-key',
})
# Disable the use of the plugin manager in the transformer registry for
# better performant unit tests.
from openedx.core.lib.block_structure.transformer_registry import TransformerRegistry
TransformerRegistry.USE_PLUGIN_MANAGER = False
# Set the default Oauth2 Provider Model so that migrations can run in
# verbose mode
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'

View File

@@ -3,28 +3,9 @@ Helpers for Course Blocks tests.
"""
from openedx.core.lib.block_structure.cache import BlockStructureCache
from openedx.core.lib.block_structure.transformer_registry import TransformerRegistry
from ..api import get_cache
class EnableTransformerRegistryMixin(object):
"""
Mixin that enables the TransformerRegistry to USE_PLUGIN_MANAGER for
finding registered transformers. USE_PLUGIN_MANAGER is set to False
for LMS unit tests to speed up performance of the unit tests, so all
registered transformers in the platform do not need to be collected.
This Mixin is expected to be used by Tests for integration testing
with all registered transformers.
"""
def setUp(self, **kwargs):
super(EnableTransformerRegistryMixin, self).setUp(**kwargs)
TransformerRegistry.USE_PLUGIN_MANAGER = True
def tearDown(self):
super(EnableTransformerRegistryMixin, self).tearDown()
TransformerRegistry.USE_PLUGIN_MANAGER = False
def is_course_in_block_structure_cache(course_key, store):
"""
Returns whether the given course is in the Block Structure cache.

View File

@@ -7,10 +7,10 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from ..api import get_block_structure_manager
from .helpers import is_course_in_block_structure_cache, EnableTransformerRegistryMixin
from .helpers import is_course_in_block_structure_cache
class CourseBlocksSignalTest(EnableTransformerRegistryMixin, ModuleStoreTestCase):
class CourseBlocksSignalTest(ModuleStoreTestCase):
"""
Tests for the Course Blocks signal
"""