Skip to content

Commit 2c98abc

Browse files
committed
fix: remove legacy xmodulemixin from xblocks-contrib xblocks
1 parent dc6e19e commit 2c98abc

11 files changed

Lines changed: 32 additions & 25 deletions

File tree

lms/djangoapps/course_home_api/outline/tests/test_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ def test_vertical_icon(self, block_categories, expected_icon):
881881

882882
assert vertical_data['icon'] == expected_icon
883883

884-
@patch('xmodule.html_block.HtmlBlock.icon_class', 'video')
884+
@patch('xmodule.x_module.XModuleMixin.icon_class', 'video')
885885
def test_vertical_icon_determined_by_icon_class(self):
886886
"""Test that the API checks the children `icon_class` to determine the icon for the unit."""
887887
self.add_blocks_to_course()

lms/djangoapps/courseware/tests/test_block_render.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@
4545
from xblock.exceptions import NoSuchServiceError
4646
from xblock.field_data import FieldData # lint-amnesty, pylint: disable=wrong-import-order
4747
from xblock.fields import ScopeIds # lint-amnesty, pylint: disable=wrong-import-order
48-
from xblock.runtime import DictKeyValueStore, KvsFieldData # lint-amnesty, pylint: disable=wrong-import-order
48+
from xblock.runtime import ( # lint-amnesty, pylint: disable=wrong-import-order
49+
DictKeyValueStore,
50+
KvsFieldData,
51+
Mixologist, # lint-amnesty, pylint: disable=wrong-import-order
52+
)
4953
from xblock.test.tools import TestRuntime # lint-amnesty, pylint: disable=wrong-import-order
5054
from xblocks_contrib.problem.capa.tests.response_xml_factory import (
5155
OptionResponseXMLFactory, # lint-amnesty, pylint: disable=reimported
@@ -1931,8 +1935,9 @@ def setUp(self):
19311935
@patch('lms.djangoapps.courseware.block_render.has_access', Mock(return_value=True, autospec=True))
19321936
def _get_anonymous_id(self, course_id, xblock_class, should_get_deprecated_id: bool): # lint-amnesty, pylint: disable=missing-function-docstring
19331937
location = course_id.make_usage_key('dummy_category', 'dummy_name')
1938+
mixed_class = Mixologist(settings.XBLOCK_MIXINS).mix(xblock_class)
19341939
block = Mock(
1935-
spec=xblock_class,
1940+
spec=mixed_class,
19361941
_field_data=Mock(spec=FieldData, name='field_data'),
19371942
location=location,
19381943
static_asset_path=None,
@@ -1951,8 +1956,7 @@ def _get_anonymous_id(self, course_id, xblock_class, should_get_deprecated_id: b
19511956
days_early_for_beta=None,
19521957
)
19531958
block.runtime = ModuleStoreRuntime(None, None, None)
1954-
# Use the xblock_class's bind_for_student method
1955-
block.bind_for_student = partial(xblock_class.bind_for_student, block)
1959+
block.bind_for_student = partial(mixed_class.bind_for_student, block)
19561960

19571961
if hasattr(xblock_class, 'module_class'):
19581962
block.module_class = xblock_class.module_class

lms/djangoapps/courseware/tests/test_discussion_xblock.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def setUp(self):
5555
})
5656
scope_ids = mock.Mock()
5757
scope_ids.usage_id.course_key = self.course_id
58+
scope_ids.usage_id.context_key = self.course_id
5859
self.block = DiscussionXBlock(
5960
self.runtime,
6061
field_data=self.data,

openedx/envs/common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ def add_optional_apps(optional_apps, installed_apps):
20872087
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
20882088
# .. toggle_creation_date: 2024-11-10
20892089
# .. toggle_target_removal_date: 2026-04-10
2090-
USE_EXTRACTED_DISCUSSION_BLOCK = False
2090+
USE_EXTRACTED_DISCUSSION_BLOCK = True
20912091

20922092
# .. toggle_name: USE_EXTRACTED_PROBLEM_BLOCK
20932093
# .. toggle_default: False
@@ -2097,7 +2097,7 @@ def add_optional_apps(optional_apps, installed_apps):
20972097
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
20982098
# .. toggle_creation_date: 2024-11-10
20992099
# .. toggle_target_removal_date: 2026-04-10
2100-
USE_EXTRACTED_PROBLEM_BLOCK = False
2100+
USE_EXTRACTED_PROBLEM_BLOCK = True
21012101

21022102
# .. toggle_name: USE_EXTRACTED_VIDEO_BLOCK
21032103
# .. toggle_default: True

requirements/edx/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ xblock-utils==4.0.0
13071307
# via
13081308
# edx-sga
13091309
# xblock-poll
1310-
xblocks-contrib==0.15.3
1310+
git+https://github.com/openedx/xblocks-contrib.git@remove-legacy-mixins#egg=xblocks-contrib
13111311
# via -r requirements/edx/bundled.in
13121312
xmlsec==1.3.14
13131313
# via

requirements/edx/development.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2337,7 +2337,7 @@ xblock-utils==4.0.0
23372337
# -r requirements/edx/testing.txt
23382338
# edx-sga
23392339
# xblock-poll
2340-
xblocks-contrib==0.15.3
2340+
git+https://github.com/openedx/xblocks-contrib.git@remove-legacy-mixins#egg=xblocks-contrib
23412341
# via
23422342
# -r requirements/edx/doc.txt
23432343
# -r requirements/edx/testing.txt

requirements/edx/doc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ xblock-utils==4.0.0
16461646
# -r requirements/edx/base.txt
16471647
# edx-sga
16481648
# xblock-poll
1649-
xblocks-contrib==0.15.3
1649+
git+https://github.com/openedx/xblocks-contrib.git@remove-legacy-mixins#egg=xblocks-contrib
16501650
# via -r requirements/edx/base.txt
16511651
xmlsec==1.3.14
16521652
# via

requirements/edx/testing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ xblock-utils==4.0.0
17411741
# -r requirements/edx/base.txt
17421742
# edx-sga
17431743
# xblock-poll
1744-
xblocks-contrib==0.15.3
1744+
git+https://github.com/openedx/xblocks-contrib.git@remove-legacy-mixins#egg=xblocks-contrib
17451745
# via -r requirements/edx/base.txt
17461746
xmlsec==1.3.14
17471747
# via

xmodule/modulestore/tests/test_xml.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def test_get_courses_for_wiki(self):
6464
"""
6565
Test the get_courses_for_wiki method
6666
"""
67-
store = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple'])
67+
store = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple'], xblock_mixins=(XModuleMixin,))
6868
for course in store.get_courses():
6969
course_locations = store.get_courses_for_wiki(course.wiki_slug)
7070
assert len(course_locations) == 1
@@ -90,7 +90,7 @@ def test_has_course(self):
9090
Test the has_course method
9191
"""
9292
check_has_course_method(
93-
XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple']),
93+
XMLModuleStore(DATA_DIR, source_dirs=['toy', 'simple'], xblock_mixins=(XModuleMixin,)),
9494
CourseKey.from_string('edX/toy/2012_Fall'),
9595
locator_key_fields=CourseLocator.KEY_FIELDS
9696
)
@@ -99,7 +99,7 @@ def test_branch_setting(self):
9999
"""
100100
Test the branch setting context manager
101101
"""
102-
store = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
102+
store = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,))
103103
course = store.get_courses()[0]
104104

105105
# XML store allows published_only branch setting
@@ -152,7 +152,9 @@ def setUp(self):
152152

153153
@patch("xmodule.modulestore.xml.glob.glob", side_effect=glob_tildes_at_end)
154154
def test_tilde_files_ignored(self, _fake_glob): # noqa: PT019
155-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['course_ignore'], load_error_blocks=False)
155+
modulestore = XMLModuleStore(
156+
DATA_DIR, source_dirs=["course_ignore"], xblock_mixins=(XModuleMixin,), load_error_blocks=False
157+
)
156158
about_location = CourseKey.from_string('edX/course_ignore/2014_Fall').make_usage_key(
157159
'about', 'index',
158160
)

xmodule/tests/test_conditional.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from xmodule.tests.xml import XModuleXmlImportTest
2121
from xmodule.tests.xml import factories as xml
2222
from xmodule.validation import StudioValidationMessage
23-
from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW
23+
from xmodule.x_module import AUTHOR_VIEW, STUDENT_VIEW, XModuleMixin
2424

2525
ORG = 'test_org'
2626
COURSE = 'conditional' # name of directory with course data
@@ -227,7 +227,7 @@ def add_block_as_child_node(block, node):
227227
block.add_xml_to_node(child)
228228
self.test_system = get_test_system(add_get_block_overrides=True)
229229
self.test_system.add_block_as_child_node = add_block_as_child_node
230-
self.modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll'])
230+
self.modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll'], xblock_mixins=(XModuleMixin,))
231231
courses = self.modulestore.get_courses()
232232
assert len(courses) == 1
233233
self.course = courses[0]

0 commit comments

Comments
 (0)