/drafts.
draft_course_dir = draft_dir.replace(data_dir, '', 1)
- system = ImportSystem(
+ system = XMLImportingModuleStoreRuntime(
xmlstore=xml_module_store,
course_id=source_course_id,
course_dir=draft_course_dir,
diff --git a/xmodule/tests/__init__.py b/xmodule/tests/__init__.py
index d8a203f34ba8..819c89669eba 100644
--- a/xmodule/tests/__init__.py
+++ b/xmodule/tests/__init__.py
@@ -24,14 +24,13 @@
from xmodule.capa.xqueue_interface import XQueueService
from xmodule.assetstore import AssetMetadata
from xmodule.contentstore.django import contentstore
-from xmodule.mako_block import MakoDescriptorSystem
from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.draft_and_published import ModuleStoreDraftAndPublished
from xmodule.modulestore.inheritance import InheritanceMixin
from xmodule.modulestore.xml import CourseLocationManager
from xmodule.tests.helpers import StubReplaceURLService, mock_render_template, StubMakoService, StubUserService
from xmodule.util.sandboxing import SandboxService
-from xmodule.x_module import DoNothingCache, XModuleMixin
+from xmodule.x_module import DoNothingCache, XModuleMixin, ModuleStoreRuntime
from openedx.core.lib.cache_utils import CacheService
@@ -64,12 +63,12 @@ def get_asides(block):
@property
def resources_fs():
- return Mock(name='TestDescriptorSystem.resources_fs', root_path='.')
+ return Mock(name='TestModuleStoreRuntime.resources_fs', root_path='.')
-class TestDescriptorSystem(MakoDescriptorSystem): # pylint: disable=abstract-method
+class TestModuleStoreRuntime(ModuleStoreRuntime): # pylint: disable=abstract-method
"""
- DescriptorSystem for testing
+ ModuleStore-based XBlock Runtime for testing
"""
def handler_url(self, block, handler, suffix='', query='', thirdparty=False): # lint-amnesty, pylint: disable=arguments-differ
return '{usage_id}/{handler}{suffix}?{query}'.format(
@@ -90,7 +89,7 @@ def get_asides(self, block):
return []
def resources_fs(self): # lint-amnesty, pylint: disable=method-hidden
- return Mock(name='TestDescriptorSystem.resources_fs', root_path='.')
+ return Mock(name='TestModuleStoreRuntime.resources_fs', root_path='.')
def __repr__(self):
"""
@@ -117,7 +116,7 @@ def get_test_system(
add_get_block_overrides=False
):
"""
- Construct a test DescriptorSystem instance.
+ Construct a test ModuleStoreRuntime instance.
By default, the descriptor system's render_template() method simply returns the repr of the
context it is passed. You can override this by passing in a different render_template argument.
@@ -239,11 +238,11 @@ def get_block(block):
def get_test_descriptor_system(render_template=None, **kwargs):
"""
- Construct a test DescriptorSystem instance.
+ Construct a test ModuleStoreRuntime instance.
"""
field_data = DictFieldData({})
- descriptor_system = TestDescriptorSystem(
+ descriptor_system = TestModuleStoreRuntime(
load_item=Mock(name='get_test_descriptor_system.load_item'),
resources_fs=Mock(name='get_test_descriptor_system.resources_fs'),
error_tracker=Mock(name='get_test_descriptor_system.error_tracker'),
diff --git a/xmodule/tests/helpers.py b/xmodule/tests/helpers.py
index 480771b41778..c69c810d4aa2 100644
--- a/xmodule/tests/helpers.py
+++ b/xmodule/tests/helpers.py
@@ -9,7 +9,7 @@
import pytest
from path import Path as path
from xblock.reference.user_service import UserService, XBlockUser
-from xmodule.x_module import DescriptorSystem
+from xmodule.x_module import ModuleStoreRuntime
def directories_equal(directory1, directory2):
@@ -132,7 +132,7 @@ def replace_urls(self, text, static_replace_only=False):
@pytest.fixture
def override_descriptor_system(monkeypatch):
"""
- Fixture to override get_block method of DescriptorSystem
+ Fixture to override get_block method of ModuleStoreRuntime
"""
def get_block(self, usage_id, for_parent=None):
@@ -140,4 +140,4 @@ def get_block(self, usage_id, for_parent=None):
block = self.load_item(usage_id, for_parent=for_parent)
return block
- monkeypatch.setattr(DescriptorSystem, "get_block", get_block)
+ monkeypatch.setattr(ModuleStoreRuntime, "get_block", get_block)
diff --git a/xmodule/tests/test_conditional.py b/xmodule/tests/test_conditional.py
index d1fcde0c7561..8eb9e9ac071d 100644
--- a/xmodule/tests/test_conditional.py
+++ b/xmodule/tests/test_conditional.py
@@ -15,7 +15,7 @@
from xmodule.conditional_block import ConditionalBlock
from xmodule.error_block import ErrorBlock
-from xmodule.modulestore.xml import CourseLocationManager, ImportSystem, XMLModuleStore
+from xmodule.modulestore.xml import CourseLocationManager, XMLImportingModuleStoreRuntime, XMLModuleStore
from xmodule.tests import DATA_DIR, get_test_system, prepare_block_runtime
from xmodule.tests.xml import XModuleXmlImportTest
from xmodule.tests.xml import factories as xml
@@ -26,7 +26,10 @@
COURSE = 'conditional' # name of directory with course data
-class DummySystem(ImportSystem): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
+class DummyModuleStoreRuntime(XMLImportingModuleStoreRuntime): # pylint: disable=abstract-method
+ """
+ Minimal modulestore runtime for tests
+ """
@patch('xmodule.modulestore.xml.OSFS', lambda directory: MemoryFS())
def __init__(self, load_error_blocks):
diff --git a/xmodule/tests/test_course_block.py b/xmodule/tests/test_course_block.py
index f2956cca0d7e..c88b519d708e 100644
--- a/xmodule/tests/test_course_block.py
+++ b/xmodule/tests/test_course_block.py
@@ -21,7 +21,7 @@
import xmodule.course_block
from xmodule.course_metadata_utils import DEFAULT_START_DATE
from xmodule.data import CertificatesDisplayBehaviors
-from xmodule.modulestore.xml import ImportSystem, XMLModuleStore
+from xmodule.modulestore.xml import XMLImportingModuleStoreRuntime, XMLModuleStore
from xmodule.modulestore.exceptions import InvalidProctoringProvider
ORG = 'test_org'
@@ -52,7 +52,10 @@ def test_default_enrollment_start_date(self, should_have_default_enroll_start):
assert xmodule.course_block.CourseFields.enrollment_start.default == expected
-class DummySystem(ImportSystem): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
+class DummyModuleStoreRuntime(XMLImportingModuleStoreRuntime): # pylint: disable=abstract-method
+ """
+ Minimal modulestore runtime for tests.
+ """
@patch('xmodule.modulestore.xml.OSFS', lambda dir: MemoryFS())
def __init__(self, load_error_blocks, course_id=None):
@@ -83,7 +86,7 @@ def get_dummy_course(
):
"""Get a dummy course"""
- system = DummySystem(load_error_blocks=True)
+ system = DummyModuleStoreRuntime(load_error_blocks=True)
def to_attrb(n, v):
return '' if v is None else f'{n}="{v}"'.lower()
@@ -126,7 +129,7 @@ class HasEndedMayCertifyTestCase(unittest.TestCase):
def setUp(self):
super().setUp()
- system = DummySystem(load_error_blocks=True) # lint-amnesty, pylint: disable=unused-variable
+ system = DummyModuleStoreRuntime(load_error_blocks=True) # lint-amnesty, pylint: disable=unused-variable
past_end = (datetime.now() - timedelta(days=12)).strftime("%Y-%m-%dT%H:%M:00")
future_end = (datetime.now() + timedelta(days=12)).strftime("%Y-%m-%dT%H:%M:00")
diff --git a/xmodule/tests/test_import.py b/xmodule/tests/test_import.py
index 95feedeb9c76..0540f7665f1f 100644
--- a/xmodule/tests/test_import.py
+++ b/xmodule/tests/test_import.py
@@ -18,7 +18,7 @@
from xmodule.fields import Date
from xmodule.modulestore.inheritance import InheritanceMixin, compute_inherited_metadata
-from xmodule.modulestore.xml import ImportSystem, LibraryXMLModuleStore, XMLModuleStore
+from xmodule.modulestore.xml import XMLImportingModuleStoreRuntime, LibraryXMLModuleStore, XMLModuleStore
from xmodule.tests import DATA_DIR
from xmodule.x_module import XModuleMixin
from xmodule.xml_block import is_pointer_tag
@@ -28,7 +28,10 @@
RUN = 'test_run'
-class DummySystem(ImportSystem): # lint-amnesty, pylint: disable=abstract-method, missing-class-docstring
+class DummyModuleStoreRuntime(XMLImportingModuleStoreRuntime): # pylint: disable=abstract-method, missing-class-docstring
+ """
+ Minimal modulestore runtime for tests
+ """
@patch('xmodule.modulestore.xml.OSFS', lambda dir: OSFS(mkdtemp()))
def __init__(self, load_error_blocks, library=False):
@@ -58,7 +61,7 @@ class BaseCourseTestCase(TestCase):
@staticmethod
def get_system(load_error_blocks=True, library=False):
'''Get a dummy system'''
- return DummySystem(load_error_blocks, library=library)
+ return DummyModuleStoreRuntime(load_error_blocks, library=library)
def get_course(self, name):
"""Get a test course by directory name. If there's more than one, error."""
diff --git a/xmodule/tests/test_item_bank.py b/xmodule/tests/test_item_bank.py
index c27412c8b709..f29e4b847874 100644
--- a/xmodule/tests/test_item_bank.py
+++ b/xmodule/tests/test_item_bank.py
@@ -21,7 +21,7 @@
from common.djangoapps.student.tests.factories import UserFactory
from ..item_bank_block import ItemBankBlock
-from .test_course_block import DummySystem as TestImportSystem
+from .test_course_block import DummyModuleStoreRuntime
dummy_render = lambda block, _: Fragment(block.data) # pylint: disable=invalid-name
@@ -121,7 +121,7 @@ def test_xml_export_import_cycle(self):
olx_element = etree.fromstring(actual_olx_export)
# Re-import the OLX.
- runtime = TestImportSystem(load_error_blocks=True, course_id=self.item_bank.context_key)
+ runtime = DummyModuleStoreRuntime(load_error_blocks=True, course_id=self.item_bank.context_key)
runtime.resources_fs = export_fs
imported_item_bank = ItemBankBlock.parse_xml(olx_element, runtime, None)
@@ -168,11 +168,11 @@ def test_max_count_validation(self):
assert self.item_bank.validate()
@patch(
- 'xmodule.modulestore.split_mongo.caching_descriptor_system.CachingDescriptorSystem.render',
+ 'xmodule.modulestore.split_mongo.runtime.SplitModuleStoreRuntime.render',
VanillaRuntime.render,
)
@patch('xmodule.capa_block.ProblemBlock.author_view', dummy_render, create=True)
- @patch('xmodule.x_module.DescriptorSystem.applicable_aside_types', lambda self, block: [])
+ @patch('xmodule.x_module.ModuleStoreRuntime.applicable_aside_types', lambda self, block: [])
def test_preview_view(self):
""" Test preview view rendering """
self._bind_course_block(self.item_bank)
@@ -183,11 +183,11 @@ def test_preview_view(self):
assert 'Hello world from problem 3
' in rendered.content
@patch(
- 'xmodule.modulestore.split_mongo.caching_descriptor_system.CachingDescriptorSystem.render',
+ 'xmodule.modulestore.split_mongo.runtime.SplitModuleStoreRuntime.render',
VanillaRuntime.render,
)
@patch('xmodule.capa_block.ProblemBlock.author_view', dummy_render, create=True)
- @patch('xmodule.x_module.DescriptorSystem.applicable_aside_types', lambda self, block: [])
+ @patch('xmodule.x_module.ModuleStoreRuntime.applicable_aside_types', lambda self, block: [])
def test_author_view(self):
""" Test author view rendering """
self._bind_course_block(self.item_bank)
diff --git a/xmodule/tests/test_library_content.py b/xmodule/tests/test_library_content.py
index a5d37cff4288..01d27fad98d0 100644
--- a/xmodule/tests/test_library_content.py
+++ b/xmodule/tests/test_library_content.py
@@ -27,7 +27,7 @@
from xmodule.validation import StudioValidationMessage
from xmodule.x_module import AUTHOR_VIEW
-from .test_course_block import DummySystem as TestImportSystem
+from .test_course_block import DummyModuleStoreRuntime
dummy_render = lambda block, _: Fragment(block.data) # pylint: disable=invalid-name
@@ -167,7 +167,7 @@ def setUp(self):
self.lc_block.runtime.export_fs = self.export_fs # pylint: disable=protected-access
# Prepare runtime for the import.
- self.runtime = TestImportSystem(load_error_blocks=True, course_id=self.lc_block.location.course_key)
+ self.runtime = DummyModuleStoreRuntime(load_error_blocks=True, course_id=self.lc_block.location.course_key)
self.runtime.resources_fs = self.export_fs
self.id_generator = Mock()
@@ -521,10 +521,10 @@ def setUp(self):
@patch(
- 'xmodule.modulestore.split_mongo.caching_descriptor_system.CachingDescriptorSystem.render', VanillaRuntime.render
+ 'xmodule.modulestore.split_mongo.runtime.SplitModuleStoreRuntime.render', VanillaRuntime.render
)
@patch('xmodule.html_block.HtmlBlock.author_view', dummy_render, create=True)
-@patch('xmodule.x_module.DescriptorSystem.applicable_aside_types', lambda self, block: [])
+@patch('xmodule.x_module.ModuleStoreRuntime.applicable_aside_types', lambda self, block: [])
class TestLibraryContentRender(LegacyLibraryContentTest):
"""
Rendering unit tests for LegacyLibraryContentBlock
@@ -732,10 +732,10 @@ def test_removed_invalid(self):
@patch(
- 'xmodule.modulestore.split_mongo.caching_descriptor_system.CachingDescriptorSystem.render', VanillaRuntime.render
+ 'xmodule.modulestore.split_mongo.runtime.SplitModuleStoreRuntime.render', VanillaRuntime.render
)
@patch('xmodule.html_block.HtmlBlock.author_view', dummy_render, create=True)
-@patch('xmodule.x_module.DescriptorSystem.applicable_aside_types', lambda self, block: [])
+@patch('xmodule.x_module.ModuleStoreRuntime.applicable_aside_types', lambda self, block: [])
class TestMigratedLibraryContentRender(LegacyLibraryContentTest):
"""
Rendering unit tests for LegacyLibraryContentBlock
@@ -825,7 +825,7 @@ def test_xml_export_import_cycle(self):
assert exported_olx == expected_olx_export
# Now import it.
- runtime = TestImportSystem(load_error_blocks=True, course_id=self.lc_block.location.course_key)
+ runtime = DummyModuleStoreRuntime(load_error_blocks=True, course_id=self.lc_block.location.course_key)
runtime.resources_fs = export_fs
olx_element = etree.fromstring(exported_olx)
imported_lc_block = LegacyLibraryContentBlock.parse_xml(olx_element, runtime, None)
diff --git a/xmodule/tests/test_library_root.py b/xmodule/tests/test_library_root.py
index 0390aaa7ccce..bcc2b6af7174 100644
--- a/xmodule/tests/test_library_root.py
+++ b/xmodule/tests/test_library_root.py
@@ -15,11 +15,11 @@
@patch(
- 'xmodule.modulestore.split_mongo.caching_descriptor_system.CachingDescriptorSystem.render', VanillaRuntime.render
+ 'xmodule.modulestore.split_mongo.runtime.SplitModuleStoreRuntime.render', VanillaRuntime.render
)
@patch('xmodule.html_block.HtmlBlock.author_view', dummy_render, create=True)
@patch('xmodule.html_block.HtmlBlock.has_author_view', True, create=True)
-@patch('xmodule.x_module.DescriptorSystem.applicable_aside_types', lambda self, block: [])
+@patch('xmodule.x_module.ModuleStoreRuntime.applicable_aside_types', lambda self, block: [])
class TestLibraryRoot(MixedSplitTestCase):
"""
Basic unit tests for LibraryRoot (library_root_xblock.py)
diff --git a/xmodule/tests/test_poll.py b/xmodule/tests/test_poll.py
index e04aab2b9fd2..440dde41e082 100644
--- a/xmodule/tests/test_poll.py
+++ b/xmodule/tests/test_poll.py
@@ -11,7 +11,7 @@
from openedx.core.lib.safe_lxml import etree
from xmodule import poll_block
from . import get_test_system
-from .test_import import DummySystem
+from .test_import import DummyModuleStoreRuntime
class _PollBlockTestBase(TestCase):
@@ -67,7 +67,7 @@ def test_poll_export_with_unescaped_characters_xml(self):
Make sure that poll_block will export fine if its xml contains
unescaped characters.
"""
- module_system = DummySystem(load_error_blocks=True)
+ module_system = DummyModuleStoreRuntime(load_error_blocks=True)
module_system.id_generator.target_course_id = self.xblock.course_id
sample_poll_xml = '''
diff --git a/xmodule/tests/test_randomize_block.py b/xmodule/tests/test_randomize_block.py
index 52413faad3b7..feffd7d2f12a 100644
--- a/xmodule/tests/test_randomize_block.py
+++ b/xmodule/tests/test_randomize_block.py
@@ -11,7 +11,7 @@
from xmodule.randomize_block import RandomizeBlock
from xmodule.tests import prepare_block_runtime
-from .test_course_block import DummySystem as TestImportSystem
+from .test_course_block import DummyModuleStoreRuntime
class RandomizeBlockTest(MixedSplitTestCase):
@@ -78,7 +78,7 @@ def test_xml_export_import_cycle(self):
# And compare.
assert exported_olx == expected_olx
- runtime = TestImportSystem(load_error_blocks=True, course_id=randomize_block.location.course_key)
+ runtime = DummyModuleStoreRuntime(load_error_blocks=True, course_id=randomize_block.location.course_key)
runtime.resources_fs = export_fs
# Now import it.
diff --git a/xmodule/tests/test_split_test_block.py b/xmodule/tests/test_split_test_block.py
index c51c157a7760..7acbaa25f6ba 100644
--- a/xmodule/tests/test_split_test_block.py
+++ b/xmodule/tests/test_split_test_block.py
@@ -19,7 +19,7 @@
user_partition_values,
)
from xmodule.tests import prepare_block_runtime
-from xmodule.tests.test_course_block import DummySystem as TestImportSystem
+from xmodule.tests.test_course_block import DummyModuleStoreRuntime
from xmodule.tests.xml import XModuleXmlImportTest
from xmodule.tests.xml import factories as xml
from xmodule.validation import StudioValidationMessage
@@ -581,7 +581,7 @@ def test_xml_export_import_cycle(self):
# And compare.
assert exported_olx == expected_olx
- runtime = TestImportSystem(load_error_blocks=True, course_id=split_test_block.location.course_key)
+ runtime = DummyModuleStoreRuntime(load_error_blocks=True, course_id=split_test_block.location.course_key)
runtime.resources_fs = export_fs
# Now import it.
diff --git a/xmodule/tests/test_video.py b/xmodule/tests/test_video.py
index 1179feebf324..39d0abf2c27f 100644
--- a/xmodule/tests/test_video.py
+++ b/xmodule/tests/test_video.py
@@ -40,7 +40,7 @@
from xblock.core import XBlockAside
from xmodule.modulestore.tests.test_asides import AsideTestType
-from .test_import import DummySystem
+from .test_import import DummyModuleStoreRuntime
SRT_FILEDATA = '''
0
@@ -283,7 +283,7 @@ def test_constructor(self):
})
def test_parse_xml(self):
- module_system = DummySystem(load_error_blocks=True)
+ module_system = DummyModuleStoreRuntime(load_error_blocks=True)
xml_data = '''