Commit f016647f by Nimisha Asthagiri

Enable Block Transformer Registry in tests

parent 85687dcf
...@@ -4,7 +4,6 @@ Tests for Blocks api.py ...@@ -4,7 +4,6 @@ Tests for Blocks api.py
from django.test.client import RequestFactory from django.test.client import RequestFactory
from openedx.core.djangoapps.content.block_structure.tests.helpers import EnableTransformerRegistryMixin
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
...@@ -13,7 +12,7 @@ from xmodule.modulestore.tests.factories import SampleCourseFactory ...@@ -13,7 +12,7 @@ from xmodule.modulestore.tests.factories import SampleCourseFactory
from ..api import get_blocks from ..api import get_blocks
class TestGetBlocks(EnableTransformerRegistryMixin, SharedModuleStoreTestCase): class TestGetBlocks(SharedModuleStoreTestCase):
""" """
Tests for the get_blocks function Tests for the get_blocks function
""" """
......
...@@ -7,7 +7,6 @@ from urllib import urlencode ...@@ -7,7 +7,6 @@ from urllib import urlencode
from rest_framework.exceptions import PermissionDenied from rest_framework.exceptions import PermissionDenied
from opaque_keys.edx.locator import CourseLocator 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 openedx.core.djangoapps.util.test_forms import FormTestMixin
from student.models import CourseEnrollment from student.models import CourseEnrollment
from student.tests.factories import UserFactory, CourseEnrollmentFactory from student.tests.factories import UserFactory, CourseEnrollmentFactory
...@@ -18,7 +17,7 @@ from ..forms import BlockListGetForm ...@@ -18,7 +17,7 @@ from ..forms import BlockListGetForm
@ddt.ddt @ddt.ddt
class TestBlockListGetForm(EnableTransformerRegistryMixin, FormTestMixin, SharedModuleStoreTestCase): class TestBlockListGetForm(FormTestMixin, SharedModuleStoreTestCase):
""" """
Tests for BlockListGetForm Tests for BlockListGetForm
""" """
......
...@@ -3,7 +3,6 @@ Tests for Course Blocks serializers ...@@ -3,7 +3,6 @@ Tests for Course Blocks serializers
""" """
from mock import MagicMock 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 openedx.core.lib.block_structure.transformers import BlockStructureTransformers
from student.tests.factories import UserFactory from student.tests.factories import UserFactory
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
...@@ -17,7 +16,7 @@ from ..serializers import BlockSerializer, BlockDictSerializer ...@@ -17,7 +16,7 @@ from ..serializers import BlockSerializer, BlockDictSerializer
from .helpers import deserialize_usage_key from .helpers import deserialize_usage_key
class TestBlockSerializerBase(EnableTransformerRegistryMixin, SharedModuleStoreTestCase): class TestBlockSerializerBase(SharedModuleStoreTestCase):
""" """
Base class for testing BlockSerializer and BlockDictSerializer Base class for testing BlockSerializer and BlockDictSerializer
""" """
......
...@@ -8,7 +8,6 @@ from urllib import urlencode ...@@ -8,7 +8,6 @@ from urllib import urlencode
from urlparse import urlunparse from urlparse import urlunparse
from opaque_keys.edx.locator import CourseLocator 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.models import CourseEnrollment
from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory from student.tests.factories import AdminFactory, CourseEnrollmentFactory, UserFactory
from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase from xmodule.modulestore.tests.django_utils import SharedModuleStoreTestCase
...@@ -17,7 +16,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory ...@@ -17,7 +16,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory
from .helpers import deserialize_usage_key from .helpers import deserialize_usage_key
class TestBlocksView(EnableTransformerRegistryMixin, SharedModuleStoreTestCase): class TestBlocksView(SharedModuleStoreTestCase):
""" """
Test class for BlocksView Test class for BlocksView
""" """
......
...@@ -6,7 +6,6 @@ from mock import Mock ...@@ -6,7 +6,6 @@ from mock import Mock
from . import BaseTestXmodule from . import BaseTestXmodule
from course_api.blocks.tests.helpers import deserialize_usage_key from course_api.blocks.tests.helpers import deserialize_usage_key
from courseware.module_render import get_module_for_descriptor_internal 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 student.tests.factories import UserFactory, CourseEnrollmentFactory
from xmodule.discussion_module import DiscussionModule from xmodule.discussion_module import DiscussionModule
from xmodule.modulestore import ModuleStoreEnum from xmodule.modulestore import ModuleStoreEnum
...@@ -16,7 +15,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory, ItemFactory ...@@ -16,7 +15,7 @@ from xmodule.modulestore.tests.factories import ToyCourseFactory, ItemFactory
@ddt.ddt @ddt.ddt
class DiscussionModuleTest(BaseTestXmodule, EnableTransformerRegistryMixin, SharedModuleStoreTestCase): class DiscussionModuleTest(BaseTestXmodule, SharedModuleStoreTestCase):
"""Logic tests for Discussion Xmodule.""" """Logic tests for Discussion Xmodule."""
CATEGORY = "discussion" CATEGORY = "discussion"
......
...@@ -577,11 +577,6 @@ JWT_AUTH.update({ ...@@ -577,11 +577,6 @@ JWT_AUTH.update({
'JWT_AUDIENCE': 'test-key', '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 # Set the default Oauth2 Provider Model so that migrations can run in
# verbose mode # verbose mode
OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application' OAUTH2_PROVIDER_APPLICATION_MODEL = 'oauth2_provider.Application'
......
...@@ -3,28 +3,9 @@ Helpers for Course Blocks tests. ...@@ -3,28 +3,9 @@ Helpers for Course Blocks tests.
""" """
from openedx.core.lib.block_structure.cache import BlockStructureCache from openedx.core.lib.block_structure.cache import BlockStructureCache
from openedx.core.lib.block_structure.transformer_registry import TransformerRegistry
from ..api import get_cache 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): def is_course_in_block_structure_cache(course_key, store):
""" """
Returns whether the given course is in the Block Structure cache. Returns whether the given course is in the Block Structure cache.
......
...@@ -7,10 +7,10 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase ...@@ -7,10 +7,10 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory from xmodule.modulestore.tests.factories import CourseFactory
from ..api import get_block_structure_manager 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 Tests for the Course Blocks signal
""" """
......
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