Skip to content

refactor: migrate MOCK_SETTINGS and mfe_config test overrides off FEATURES-as-dict - #39018

Draft
feanil wants to merge 2 commits into
masterfrom
feanil/features-dict-remove-test-overrides
Draft

refactor: migrate MOCK_SETTINGS and mfe_config test overrides off FEATURES-as-dict#39018
feanil wants to merge 2 commits into
masterfrom
feanil/features-dict-remove-test-overrides

Conversation

@feanil

@feanil feanil commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Two test-only spots that still set flags through the FEATURES dict.

  • common/djangoapps/student/tests/test_views.pyStudentDashboardTests applied 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 (user_authn/cookies.py) reads the flat settings.DISABLE_SET_JWT_COOKIES_FOR_TESTS, so the key moves to the top level of both mock dicts (matching the DISABLE_START_DATES entry already there) and the now-empty FEATURES sub-dicts are dropped.
  • lms/djangoapps/mfe_config_api/tests/test_views.pytest_config_order_of_precedence overrode FEATURES={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 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 (MFE_CONFIG takes precedence).

Verified: test_config_order_of_precedence passes; the two StudentDashboardTests methods that use the mock dicts pass (5); ruff clean.

feanil and others added 2 commits August 24, 2026 11:16
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant