refactor: migrated FEATURES dict settings to top-level in core files and fixed related test files. (#37389)

* refactor: moved remaining feature dicts settings into top-level settings.

* refactor: moved remaining feature dicts settings into top-level settings.

* fix: fixed the test files

* fix: fixed tehe pylint errors

* fix: fixation of the cms ci failure

* fix: fixed remaining feature settings for cms

* fix: added fix for requirements

* fix: added fix for lms tests

* fix: resolved the test views issue

* fix: configured views file and test_views

* fix: fixed lint errors and assertion issues

* fix: added fix for base url issue in test view

* fix: added fix for base_url and assertion issue

* fix: added configurations for base utl fix

* fix: handled none issue for mfe config

* fix: corrected override settings in test views

* fix: added getattr defensive technique for view settings

* fix: reverted views and test_views file

* fix: added settings in views file

* fix: added with patch within functions in test view

* fix: rearranged the features in default_legacy_config

* fix: fixing the tests  with clearing cache

* fix: reverted test views to verify the CI check

* fix: added cache clear in mfe config test

* fix: fixed the patch toggles to override settings

* fix: fixed the lint errors

* fix: changed patch toggle to override settings
This commit is contained in:
Akanshu Aich
2026-01-20 22:25:26 +05:30
committed by GitHub
parent 7ecb6cb79b
commit 2d82d90279
23 changed files with 88 additions and 84 deletions

View File

@@ -12,7 +12,7 @@ import dateutil.parser
import requests
from django.conf import settings
from django.core.validators import validate_email
from edx_toggles.toggles import SettingDictToggle
from edx_toggles.toggles import SettingToggle
from lazy import lazy
from lxml import etree
from path import Path as path
@@ -59,8 +59,8 @@ COURSE_VISIBILITY_PRIVATE = 'private'
COURSE_VISIBILITY_PUBLIC_OUTLINE = 'public_outline'
COURSE_VISIBILITY_PUBLIC = 'public'
# .. toggle_name: FEATURES['CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE']
# .. toggle_implementation: SettingDictToggle
# .. toggle_name: CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE
# .. toggle_implementation: SettingToggle
# .. toggle_default: False
# .. toggle_description: The default behavior, when this is disabled, is that a newly created course has no
# enrollment_start date set. When the feature is enabled - the newly created courses will have the
@@ -71,8 +71,8 @@ COURSE_VISIBILITY_PUBLIC = 'public'
# the newly created (empty) course from appearing in the course listing.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2023-06-22
CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE = SettingDictToggle(
"FEATURES", "CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE", default=False, module_name=__name__
CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE = SettingToggle(
"CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE", default=False, module_name=__name__
)

View File

@@ -23,7 +23,7 @@ from xblock.exceptions import NoSuchServiceError
from xblock.fields import Boolean, Date, Integer, List, Scope, String
from xblock.progress import Progress
from edx_toggles.toggles import WaffleFlag, SettingDictToggle
from edx_toggles.toggles import WaffleFlag, SettingToggle
from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_css_to_fragment
from xmodule.x_module import (
ResourceTemplates,
@@ -54,14 +54,14 @@ TIMED_EXAM_GATING_WAFFLE_FLAG = WaffleFlag( # lint-amnesty, pylint: disable=tog
'xmodule.rev_1377_rollout', __name__
)
# .. toggle_name: FEATURES['SHOW_PROGRESS_BAR']
# .. toggle_implementation: SettingDictToggle
# .. toggle_name: SHOW_PROGRESS_BAR
# .. toggle_implementation: SettingToggle
# .. toggle_default: False
# .. toggle_description: Set to True to show progress bar.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2022-02-09
# .. toggle_target_removal_date: None
SHOW_PROGRESS_BAR = SettingDictToggle("FEATURES", "SHOW_PROGRESS_BAR", default=False, module_name=__name__)
SHOW_PROGRESS_BAR = SettingToggle("SHOW_PROGRESS_BAR", default=False, module_name=__name__)
class SequenceFields: # lint-amnesty, pylint: disable=missing-class-docstring

View File

@@ -42,9 +42,7 @@ class CourseFieldsTestCase(unittest.TestCase): # lint-amnesty, pylint: disable=
@ddt.data(True, False)
def test_default_enrollment_start_date(self, should_have_default_enroll_start):
features = settings.FEATURES.copy()
features['CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE'] = should_have_default_enroll_start
with override_settings(FEATURES=features):
with override_settings(CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE=should_have_default_enroll_start):
# reimport, so settings override could take effect
del sys.modules['xmodule.course_block']
import xmodule.course_block # lint-amnesty, pylint: disable=redefined-outer-name, reimported