diff --git a/lms/djangoapps/course_home_api/outline/tests/test_view.py b/lms/djangoapps/course_home_api/outline/tests/test_view.py index c744a33ee048..e9a3570ea6bd 100644 --- a/lms/djangoapps/course_home_api/outline/tests/test_view.py +++ b/lms/djangoapps/course_home_api/outline/tests/test_view.py @@ -881,7 +881,7 @@ def test_vertical_icon(self, block_categories, expected_icon): assert vertical_data['icon'] == expected_icon - @patch('xmodule.html_block.HtmlBlock.icon_class', 'video') + @patch('xmodule.x_module.XModuleMixin.icon_class', 'video') def test_vertical_icon_determined_by_icon_class(self): """Test that the API checks the children `icon_class` to determine the icon for the unit.""" self.add_blocks_to_course() diff --git a/lms/djangoapps/courseware/tests/test_block_render.py b/lms/djangoapps/courseware/tests/test_block_render.py index a55ac3298b2e..d7d13141ef98 100644 --- a/lms/djangoapps/courseware/tests/test_block_render.py +++ b/lms/djangoapps/courseware/tests/test_block_render.py @@ -45,7 +45,11 @@ from xblock.exceptions import NoSuchServiceError from xblock.field_data import FieldData # lint-amnesty, pylint: disable=wrong-import-order from xblock.fields import ScopeIds # lint-amnesty, pylint: disable=wrong-import-order -from xblock.runtime import DictKeyValueStore, KvsFieldData # lint-amnesty, pylint: disable=wrong-import-order +from xblock.runtime import ( # lint-amnesty, pylint: disable=wrong-import-order + DictKeyValueStore, + KvsFieldData, + Mixologist, # lint-amnesty, pylint: disable=wrong-import-order +) from xblock.test.tools import TestRuntime # lint-amnesty, pylint: disable=wrong-import-order from xblocks_contrib.problem.capa.tests.response_xml_factory import ( OptionResponseXMLFactory, # lint-amnesty, pylint: disable=reimported @@ -1931,8 +1935,9 @@ def setUp(self): @patch('lms.djangoapps.courseware.block_render.has_access', Mock(return_value=True, autospec=True)) def _get_anonymous_id(self, course_id, xblock_class, should_get_deprecated_id: bool): # lint-amnesty, pylint: disable=missing-function-docstring location = course_id.make_usage_key('dummy_category', 'dummy_name') + mixed_class = Mixologist(settings.XBLOCK_MIXINS).mix(xblock_class) block = Mock( - spec=xblock_class, + spec=mixed_class, _field_data=Mock(spec=FieldData, name='field_data'), location=location, static_asset_path=None, @@ -1951,8 +1956,7 @@ def _get_anonymous_id(self, course_id, xblock_class, should_get_deprecated_id: b days_early_for_beta=None, ) block.runtime = ModuleStoreRuntime(None, None, None) - # Use the xblock_class's bind_for_student method - block.bind_for_student = partial(xblock_class.bind_for_student, block) + block.bind_for_student = partial(mixed_class.bind_for_student, block) if hasattr(xblock_class, 'module_class'): block.module_class = xblock_class.module_class diff --git a/requirements/edx/base.txt b/requirements/edx/base.txt index 9502f3ebb7ca..ba3a646fc8e5 100644 --- a/requirements/edx/base.txt +++ b/requirements/edx/base.txt @@ -1317,7 +1317,7 @@ xblock-utils==4.0.0 # via # edx-sga # xblock-poll -xblocks-contrib==0.15.3 +xblocks-contrib==0.16.0 # via -r requirements/edx/bundled.in xmlsec==1.3.14 # via diff --git a/requirements/edx/development.txt b/requirements/edx/development.txt index be6cc6d9133d..aa6ac6fb3005 100644 --- a/requirements/edx/development.txt +++ b/requirements/edx/development.txt @@ -2351,7 +2351,7 @@ xblock-utils==4.0.0 # -r requirements/edx/testing.txt # edx-sga # xblock-poll -xblocks-contrib==0.15.3 +xblocks-contrib==0.16.0 # via # -r requirements/edx/doc.txt # -r requirements/edx/testing.txt diff --git a/requirements/edx/doc.txt b/requirements/edx/doc.txt index 6cb54be47ffa..8a9fa86293a5 100644 --- a/requirements/edx/doc.txt +++ b/requirements/edx/doc.txt @@ -1656,7 +1656,7 @@ xblock-utils==4.0.0 # -r requirements/edx/base.txt # edx-sga # xblock-poll -xblocks-contrib==0.15.3 +xblocks-contrib==0.16.0 # via -r requirements/edx/base.txt xmlsec==1.3.14 # via diff --git a/requirements/edx/testing.txt b/requirements/edx/testing.txt index 834c3516c715..635ee2ff9e20 100644 --- a/requirements/edx/testing.txt +++ b/requirements/edx/testing.txt @@ -1754,7 +1754,7 @@ xblock-utils==4.0.0 # -r requirements/edx/base.txt # edx-sga # xblock-poll -xblocks-contrib==0.15.3 +xblocks-contrib==0.16.0 # via -r requirements/edx/base.txt xmlsec==1.3.14 # via diff --git a/xmodule/modulestore/tests/test_xml.py b/xmodule/modulestore/tests/test_xml.py index 5627ea451b2f..608ebad7b66d 100644 --- a/xmodule/modulestore/tests/test_xml.py +++ b/xmodule/modulestore/tests/test_xml.py @@ -64,7 +64,7 @@ def test_get_courses_for_wiki(self): """ Test the get_courses_for_wiki method """ - store = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple']) + store = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple'], xblock_mixins=(XModuleMixin,)) for course in store.get_courses(): course_locations = store.get_courses_for_wiki(course.wiki_slug) assert len(course_locations) == 1 @@ -90,7 +90,7 @@ def test_has_course(self): Test the has_course method """ check_has_course_method( - XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple']), + XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple'], xblock_mixins=(XModuleMixin,)), CourseKey.from_string('edX/toy/2012_Fall'), locator_key_fields=CourseLocator.KEY_FIELDS ) @@ -99,7 +99,7 @@ def test_branch_setting(self): """ Test the branch setting context manager """ - store = XMLModuleStore(DATA_DIR, source_dirs=['toy']) + store = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,)) course = store.get_courses()[0] # XML store allows published_only branch setting @@ -152,7 +152,9 @@ def setUp(self): @patch("xmodule.modulestore.xml.glob.glob", side_effect=glob_tildes_at_end) def test_tilde_files_ignored(self, _fake_glob): # noqa: PT019 - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['course_ignore'], load_error_blocks=False) + modulestore = XMLModuleStore( + DATA_DIR, source_dirs=["course_ignore"], xblock_mixins=(XModuleMixin,), load_error_blocks=False + ) about_location = CourseKey.from_string('edX/course_ignore/2014_Fall').make_usage_key( 'about', 'index', ) diff --git a/xmodule/tests/test_conditional.py b/xmodule/tests/test_conditional.py index 6ddb2b44a0fb..d096b186986d 100644 --- a/xmodule/tests/test_conditional.py +++ b/xmodule/tests/test_conditional.py @@ -20,7 +20,7 @@ from xmodule.tests.xml import XModuleXmlImportTest from xmodule.tests.xml import factories as xml from xmodule.validation import StudioValidationMessage -from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW +from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW, XModuleMixin ORG = 'test_org' COURSE = 'conditional' # name of directory with course data @@ -227,7 +227,7 @@ def add_block_as_child_node(block, node): block.add_xml_to_node(child) self.test_system = get_test_system(add_get_block_overrides=True) self.test_system.add_block_as_child_node = add_block_as_child_node - self.modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll']) + self.modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll'], xblock_mixins=(XModuleMixin,)) courses = self.modulestore.get_courses() assert len(courses) == 1 self.course = courses[0] diff --git a/xmodule/tests/test_import.py b/xmodule/tests/test_import.py index 3c92d924b64f..126914c5bb43 100644 --- a/xmodule/tests/test_import.py +++ b/xmodule/tests/test_import.py @@ -69,7 +69,7 @@ def get_course(self, name): modulestore = XMLModuleStore( DATA_DIR, source_dirs=[name], - xblock_mixins=(InheritanceMixin,), + xblock_mixins=(InheritanceMixin, XModuleMixin), ) courses = modulestore.get_courses() assert len(courses) == 1 @@ -461,7 +461,7 @@ def test_policy_loading(self): def test_static_tabs_import(self): """Make sure that the static tabs are imported correctly""" - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy']) + modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,)) location_tab_syllabus = BlockUsageLocator(CourseLocator("edX", "toy", "2012_Fall", deprecated=True), "static_tab", "syllabus", deprecated=True) @@ -483,7 +483,7 @@ def test_definition_loading(self): happen--locations should uniquely name definitions. But in our imperfect XML world, it can (and likely will) happen.""" - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'two_toys']) + modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'two_toys'], xblock_mixins=(XModuleMixin,)) location = BlockUsageLocator(CourseLocator("edX", "toy", "2012_Fall", deprecated=True), "video", "Welcome", deprecated=True) @@ -499,7 +499,7 @@ def test_colon_in_url_name(self): print("Starting import") # Not using get_courses because we need the modulestore object too afterward - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy']) + modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,)) courses = modulestore.get_courses() assert len(courses) == 1 course = courses[0] @@ -533,7 +533,7 @@ def test_unicode(self): exceptions/errors to that effect.""" print("Starting import") - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['test_unicode']) + modulestore = XMLModuleStore(DATA_DIR, source_dirs=['test_unicode'], xblock_mixins=(XModuleMixin,)) courses = modulestore.get_courses() assert len(courses) == 1 course = courses[0] @@ -553,7 +553,7 @@ def test_url_name_mangling(self): Make sure that url_names are only mangled once. """ - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy']) + modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,)) toy_id = CourseKey.from_string('edX/toy/2012_Fall') @@ -571,7 +571,7 @@ def test_url_name_mangling(self): assert len(video.usage_key.block_id) == (len('video_') + 12) def test_poll_and_conditional_import(self): - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll']) + modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll'], xblock_mixins=(XModuleMixin,)) course = modulestore.get_courses()[0] chapters = course.get_children() @@ -624,7 +624,7 @@ def test_cohort_config(self): Note: The cohort config on the CourseBlock is no longer used. See openedx.core.djangoapps.course_groups.models.CourseCohortSettings. """ - modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy']) + modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,)) toy_id = CourseKey.from_string('edX/toy/2012_Fall') diff --git a/xmodule/x_module.py b/xmodule/x_module.py index f1d574155e80..8fa466cc1f6c 100644 --- a/xmodule/x_module.py +++ b/xmodule/x_module.py @@ -409,21 +409,6 @@ def get_asides(self): """ return self._asides - def get_explicitly_set_fields_by_scope(self, scope=Scope.content): - """ - Get a dictionary of the fields for the given scope which are set explicitly on this xblock. (Including - any set to None.) - """ - result = {} - for field in self.fields.values(): - if field.scope == scope and field.is_set_on(self): - try: - result[field.name] = field.read_json(self) - except TypeError as exception: - exception_message = f"{exception}, Block-location:{self.location}, Field-name:{field.name}" - raise TypeError(exception_message) from exception - return result - def has_children_at_depth(self, depth): r""" Returns true if self has children at the given depth. depth==0 returns @@ -519,12 +504,6 @@ def get_child_by(self, selector): return child return None - def get_icon_class(self): - """ - Return a css class identifying this module in the context of an icon - """ - return self.icon_class - def has_dynamic_children(self): """ Returns True if this block has dynamic children for a given