refactor: migrate MOCK_SETTINGS and mfe_config test overrides off FEATURES-as-dict - #39018
Draft
feanil wants to merge 2 commits into
Draft
refactor: migrate MOCK_SETTINGS and mfe_config test overrides off FEATURES-as-dict#39018feanil wants to merge 2 commits into
feanil wants to merge 2 commits into
Conversation
… FEATURES-as-dict
StudentDashboardTests applies MOCK_SETTINGS / MOCK_SETTINGS_HIDE_COURSES via
@patch.multiple('django.conf.settings', ...), each nesting DISABLE_SET_JWT_COOKIES_FOR_TESTS
inside a 'FEATURES' sub-dict. The production reader (openedx/core/djangoapps/user_authn/
cookies.py) reads the flat settings.DISABLE_SET_JWT_COOKIES_FOR_TESTS, so move the key to the
top level of both mock dicts (matching the DISABLE_START_DATES entry already there) and drop
the now-empty FEATURES sub-dicts.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
test_config_order_of_precedence overrode FEATURES={ENABLE_COURSE_SORTING_BY_START_DATE: True,
ENABLE_COURSE_DISCOVERY: True} as a "settings FEATURES" layer, but the mfe_config view reads
those flags as flat settings (get_legacy_config reads settings.ENABLE_COURSE_SORTING_BY_START_DATE
and settings.ENABLE_COURSE_DISCOVERY), so the FEATURES override never reached the view. Set them
as flat override_settings -- the plain-settings layer the test intends. No assertion depends on
ENABLE_COURSE_DISCOVERY, and the ENABLE_COURSE_SORTING_BY_START_DATE assertion still holds because
MFE_CONFIG takes precedence over plain settings.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two test-only spots that still set flags through the
FEATURESdict.common/djangoapps/student/tests/test_views.py—StudentDashboardTestsappliedMOCK_SETTINGS/MOCK_SETTINGS_HIDE_COURSESvia@patch.multiple('django.conf.settings', ...), each nestingDISABLE_SET_JWT_COOKIES_FOR_TESTSinside a'FEATURES'sub-dict. The production reader (user_authn/cookies.py) reads the flatsettings.DISABLE_SET_JWT_COOKIES_FOR_TESTS, so the key moves to the top level of both mock dicts (matching theDISABLE_START_DATESentry already there) and the now-emptyFEATURESsub-dicts are dropped.lms/djangoapps/mfe_config_api/tests/test_views.py—test_config_order_of_precedenceoverrodeFEATURES={ENABLE_COURSE_SORTING_BY_START_DATE, ENABLE_COURSE_DISCOVERY}as a "settings FEATURES" layer, but the view (get_legacy_config) reads those flags as flat settings, so the override never reached it. Set them as flatoverride_settings— the plain-settings layer the test intends. No assertion depends onENABLE_COURSE_DISCOVERY, and theENABLE_COURSE_SORTING_BY_START_DATEassertion still holds (MFE_CONFIG takes precedence).Verified:
test_config_order_of_precedencepasses; the twoStudentDashboardTestsmethods that use the mock dicts pass (5);ruffclean.