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

@@ -2,12 +2,12 @@
Helpers for the credentials service.
"""
from edx_toggles.toggles import SettingDictToggle
from edx_toggles.toggles import SettingToggle
from openedx.core.djangoapps.site_configuration import helpers as config_helpers
# .. toggle_name: FEATURES['ENABLE_LEARNER_RECORDS']
# .. toggle_implementation: SettingDictToggle
# .. toggle_name: ENABLE_LEARNER_RECORDS
# .. toggle_implementation: SettingToggle
# .. toggle_default: True
# .. toggle_description: Enable learner records for the whole platform. This setting may be overridden by site- and
# org-specific site configurations with the same name.
@@ -15,8 +15,8 @@ from openedx.core.djangoapps.site_configuration import helpers as config_helpers
# setting.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2020-10-01
ENABLE_LEARNER_RECORDS = SettingDictToggle(
"FEATURES", "ENABLE_LEARNER_RECORDS", default=True, module_name=__name__
ENABLE_LEARNER_RECORDS = SettingToggle(
"ENABLE_LEARNER_RECORDS", default=True, module_name=__name__
)

View File

@@ -549,7 +549,7 @@ class TestSendGradeIfInteresting(TestCase):
_mock_is_learner_issuance_enabled
):
assert is_learner_records_enabled()
with override_settings(FEATURES={"ENABLE_LEARNER_RECORDS": False}):
with override_settings(ENABLE_LEARNER_RECORDS=False):
assert not is_learner_records_enabled()
tasks.send_grade_if_interesting(self.user, self.key, 'verified', 'downloadable', None, None)
assert not mock_send_grade_to_credentials.delay.called

View File

@@ -9,7 +9,6 @@ import pytest
import ddt
from zoneinfo import ZoneInfo
from django.conf import settings
from xmodule.modulestore import ModuleStoreEnum
from xmodule.data import CertificatesDisplayBehaviors
from xmodule.modulestore.tests.django_utils import TEST_DATA_SPLIT_MODULESTORE, ModuleStoreTestCase
@@ -33,10 +32,7 @@ class CourseDetailsTestCase(ModuleStoreTestCase):
@ddt.data(True, False)
def test_virgin_fetch(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):
course = CourseFactory.create(default_enrollment_start=should_have_default_enroll_start)
details = CourseDetails.fetch(course.id)
wrong_enrollment_start_msg = (

View File

@@ -25,13 +25,13 @@ class ToggleStateViewTests(TestCase): # lint-amnesty, pylint: disable=missing-c
response = get_toggle_state_response(is_staff=False)
assert response.status_code == 403
def test_response_with_existing_setting_dict_toggle(self):
def test_response_with_existing_setting_toggle(self):
response = get_toggle_state_response()
assert {
"name": "FEATURES['MILESTONES_APP']",
"name": "MILESTONES_APP",
"is_active": True,
"module": "common.djangoapps.util.milestones_helpers",
"class": "SettingDictToggle",
"class": "SettingToggle",
} in response.data["django_settings"]
def test_response_with_course_override(self):

View File

@@ -2,16 +2,16 @@
Feature toggles used across the platform. Toggles should only be added to this module if we don't have a better place
for them. Generally speaking, they should be added to the most appropriate app or repo.
"""
from edx_toggles.toggles import SettingDictToggle
from edx_toggles.toggles import SettingToggle
# .. toggle_name: FEATURES['ENTRANCE_EXAMS']
# .. toggle_implementation: SettingDictToggle
# .. toggle_name: ENTRANCE_EXAMS
# .. toggle_implementation: SettingToggle
# .. toggle_default: False
# .. toggle_description: Enable entrance exams feature. When enabled, students see an exam xblock as the first unit
# of the course.
# .. toggle_use_cases: open_edx
# .. toggle_creation_date: 2015-12-01
# .. toggle_tickets: https://openedx.atlassian.net/browse/SOL-40
ENTRANCE_EXAMS = SettingDictToggle(
"FEATURES", "ENTRANCE_EXAMS", default=False, module_name=__name__
ENTRANCE_EXAMS = SettingToggle(
"ENTRANCE_EXAMS", default=False, module_name=__name__
)