Skip to content

Commit a82cd98

Browse files
fix: remove legacy xmodulemixin from xblocks-contrib xblocks (#38271)
* fix: remove legacy xmodulemixin from xblocks-contrib xblocks * feat: Upgrade Python dependency xblocks-contrib (#38399) Commit generated by workflow `openedx/openedx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master` Co-authored-by: irtazaakram <51848298+irtazaakram@users.noreply.github.com> * fix: revert extracted problem toggle * fix: remove migrated attributes from xmodulemixin * fix: add back display_name_with_default --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent eb85705 commit a82cd98

10 files changed

Lines changed: 29 additions & 44 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

requirements/edx/base.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ xblock-utils==4.0.0
13171317
# via
13181318
# edx-sga
13191319
# xblock-poll
1320-
xblocks-contrib==0.15.3
1320+
xblocks-contrib==0.16.0
13211321
# via -r requirements/edx/bundled.in
13221322
xmlsec==1.3.14
13231323
# via

requirements/edx/development.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ xblock-utils==4.0.0
23512351
# -r requirements/edx/testing.txt
23522352
# edx-sga
23532353
# xblock-poll
2354-
xblocks-contrib==0.15.3
2354+
xblocks-contrib==0.16.0
23552355
# via
23562356
# -r requirements/edx/doc.txt
23572357
# -r requirements/edx/testing.txt

requirements/edx/doc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ xblock-utils==4.0.0
16561656
# -r requirements/edx/base.txt
16571657
# edx-sga
16581658
# xblock-poll
1659-
xblocks-contrib==0.15.3
1659+
xblocks-contrib==0.16.0
16601660
# via -r requirements/edx/base.txt
16611661
xmlsec==1.3.14
16621662
# via

requirements/edx/testing.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ xblock-utils==4.0.0
17541754
# -r requirements/edx/base.txt
17551755
# edx-sga
17561756
# xblock-poll
1757-
xblocks-contrib==0.15.3
1757+
xblocks-contrib==0.16.0
17581758
# via -r requirements/edx/base.txt
17591759
xmlsec==1.3.14
17601760
# 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]

xmodule/tests/test_import.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_course(self, name):
6969
modulestore = XMLModuleStore(
7070
DATA_DIR,
7171
source_dirs=[name],
72-
xblock_mixins=(InheritanceMixin,),
72+
xblock_mixins=(InheritanceMixin, XModuleMixin),
7373
)
7474
courses = modulestore.get_courses()
7575
assert len(courses) == 1
@@ -461,7 +461,7 @@ def test_policy_loading(self):
461461
def test_static_tabs_import(self):
462462
"""Make sure that the static tabs are imported correctly"""
463463

464-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
464+
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,))
465465

466466
location_tab_syllabus = BlockUsageLocator(CourseLocator("edX", "toy", "2012_Fall", deprecated=True),
467467
"static_tab", "syllabus", deprecated=True)
@@ -483,7 +483,7 @@ def test_definition_loading(self):
483483
happen--locations should uniquely name definitions. But in
484484
our imperfect XML world, it can (and likely will) happen."""
485485

486-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'two_toys'])
486+
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy', 'two_toys'], xblock_mixins=(XModuleMixin,))
487487

488488
location = BlockUsageLocator(CourseLocator("edX", "toy", "2012_Fall", deprecated=True),
489489
"video", "Welcome", deprecated=True)
@@ -499,7 +499,7 @@ def test_colon_in_url_name(self):
499499

500500
print("Starting import")
501501
# Not using get_courses because we need the modulestore object too afterward
502-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
502+
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,))
503503
courses = modulestore.get_courses()
504504
assert len(courses) == 1
505505
course = courses[0]
@@ -533,7 +533,7 @@ def test_unicode(self):
533533
exceptions/errors to that effect."""
534534

535535
print("Starting import")
536-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['test_unicode'])
536+
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['test_unicode'], xblock_mixins=(XModuleMixin,))
537537
courses = modulestore.get_courses()
538538
assert len(courses) == 1
539539
course = courses[0]
@@ -553,7 +553,7 @@ def test_url_name_mangling(self):
553553
Make sure that url_names are only mangled once.
554554
"""
555555

556-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
556+
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,))
557557

558558
toy_id = CourseKey.from_string('edX/toy/2012_Fall')
559559

@@ -571,7 +571,7 @@ def test_url_name_mangling(self):
571571
assert len(video.usage_key.block_id) == (len('video_') + 12)
572572

573573
def test_poll_and_conditional_import(self):
574-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll'])
574+
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['conditional_and_poll'], xblock_mixins=(XModuleMixin,))
575575

576576
course = modulestore.get_courses()[0]
577577
chapters = course.get_children()
@@ -624,7 +624,7 @@ def test_cohort_config(self):
624624
Note: The cohort config on the CourseBlock is no longer used.
625625
See openedx.core.djangoapps.course_groups.models.CourseCohortSettings.
626626
"""
627-
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'])
627+
modulestore = XMLModuleStore(DATA_DIR, source_dirs=['toy'], xblock_mixins=(XModuleMixin,))
628628

629629
toy_id = CourseKey.from_string('edX/toy/2012_Fall')
630630

xmodule/x_module.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -409,21 +409,6 @@ def get_asides(self):
409409
"""
410410
return self._asides
411411

412-
def get_explicitly_set_fields_by_scope(self, scope=Scope.content):
413-
"""
414-
Get a dictionary of the fields for the given scope which are set explicitly on this xblock. (Including
415-
any set to None.)
416-
"""
417-
result = {}
418-
for field in self.fields.values():
419-
if field.scope == scope and field.is_set_on(self):
420-
try:
421-
result[field.name] = field.read_json(self)
422-
except TypeError as exception:
423-
exception_message = f"{exception}, Block-location:{self.location}, Field-name:{field.name}"
424-
raise TypeError(exception_message) from exception
425-
return result
426-
427412
def has_children_at_depth(self, depth):
428413
r"""
429414
Returns true if self has children at the given depth. depth==0 returns
@@ -519,12 +504,6 @@ def get_child_by(self, selector):
519504
return child
520505
return None
521506

522-
def get_icon_class(self):
523-
"""
524-
Return a css class identifying this module in the context of an icon
525-
"""
526-
return self.icon_class
527-
528507
def has_dynamic_children(self):
529508
"""
530509
Returns True if this block has dynamic children for a given

0 commit comments

Comments
 (0)