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:
@@ -388,15 +388,15 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin):
|
||||
(True, True, True),
|
||||
)
|
||||
@override_waffle_flag(toggles.LEGACY_STUDIO_SCHEDULE_DETAILS, True)
|
||||
@override_settings(MILESTONES_APP=False)
|
||||
def test_visibility_of_entrance_exam_section(self, feature_flags):
|
||||
"""
|
||||
Tests entrance exam section is available if ENTRANCE_EXAMS feature is enabled no matter any other
|
||||
feature is enabled or disabled i.e ENABLE_PUBLISHER.
|
||||
"""
|
||||
with patch.dict("django.conf.settings.FEATURES", {
|
||||
'ENTRANCE_EXAMS': feature_flags[0],
|
||||
'ENABLE_PUBLISHER': feature_flags[1]
|
||||
}):
|
||||
}), override_settings(ENTRANCE_EXAMS=feature_flags[0]):
|
||||
course_details_url = get_url(self.course.id)
|
||||
resp = self.client.get_html(course_details_url)
|
||||
self.assertEqual(
|
||||
@@ -405,14 +405,15 @@ class CourseDetailsViewTest(CourseTestCase, MilestonesTestCaseMixin):
|
||||
)
|
||||
|
||||
@override_waffle_flag(toggles.LEGACY_STUDIO_SCHEDULE_DETAILS, True)
|
||||
@override_settings(MILESTONES_APP=False)
|
||||
@override_settings(ENTRANCE_EXAMS=False)
|
||||
def test_marketing_site_fetch(self):
|
||||
settings_details_url = get_url(self.course.id)
|
||||
|
||||
with mock.patch.dict('django.conf.settings.FEATURES', {
|
||||
'ENABLE_PUBLISHER': True,
|
||||
'ENABLE_MKTG_SITE': True,
|
||||
'ENTRANCE_EXAMS': False,
|
||||
'ENABLE_PREREQUISITE_COURSES': False
|
||||
'ENABLE_PREREQUISITE_COURSES': False,
|
||||
}):
|
||||
response = self.client.get_html(settings_details_url)
|
||||
self.assertNotContains(response, "Course Summary Page")
|
||||
@@ -1128,7 +1129,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
self.assertIn('showanswer', test_model, 'showanswer field ')
|
||||
self.assertIn('xqa_key', test_model, 'xqa_key field ')
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_EXPORT_GIT': True})
|
||||
@override_settings(ENABLE_EXPORT_GIT=True)
|
||||
def test_fetch_giturl_present(self):
|
||||
"""
|
||||
If feature flag ENABLE_EXPORT_GIT is on, show the setting as a non-deprecated Advanced Setting.
|
||||
@@ -1136,7 +1137,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
test_model = CourseMetadata.fetch(self.fullcourse)
|
||||
self.assertIn('giturl', test_model)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_EXPORT_GIT': False})
|
||||
@override_settings(ENABLE_EXPORT_GIT=False)
|
||||
def test_fetch_giturl_not_present(self):
|
||||
"""
|
||||
If feature flag ENABLE_EXPORT_GIT is off, don't show the setting at all on the Advanced Settings page.
|
||||
@@ -1172,7 +1173,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
test_model = CourseMetadata.fetch(self.fullcourse)
|
||||
self.assertNotIn('proctoring_escalation_email', test_model)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_EXPORT_GIT': False})
|
||||
@override_settings(ENABLE_EXPORT_GIT=False)
|
||||
def test_validate_update_filtered_off(self):
|
||||
"""
|
||||
If feature flag is off, then giturl must be filtered.
|
||||
@@ -1187,7 +1188,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
)
|
||||
self.assertNotIn('giturl', test_model)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_EXPORT_GIT': True})
|
||||
@override_settings(ENABLE_EXPORT_GIT=True)
|
||||
def test_validate_update_filtered_on(self):
|
||||
"""
|
||||
If feature flag is on, then giturl must not be filtered.
|
||||
@@ -1202,7 +1203,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
)
|
||||
self.assertIn('giturl', test_model)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_EXPORT_GIT': True})
|
||||
@override_settings(ENABLE_EXPORT_GIT=True)
|
||||
def test_update_from_json_filtered_on(self):
|
||||
"""
|
||||
If feature flag is on, then giturl must be updated.
|
||||
@@ -1216,7 +1217,7 @@ class CourseMetadataEditingTest(CourseTestCase):
|
||||
)
|
||||
self.assertIn('giturl', test_model)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_EXPORT_GIT': False})
|
||||
@override_settings(ENABLE_EXPORT_GIT=False)
|
||||
def test_update_from_json_filtered_off(self):
|
||||
"""
|
||||
If feature flag is on, then giturl must not be updated.
|
||||
|
||||
@@ -892,8 +892,8 @@ class UpdateCourseDetailsTests(ModuleStoreTestCase):
|
||||
|
||||
@patch.dict("django.conf.settings.FEATURES", {
|
||||
"ENABLE_PREREQUISITE_COURSES": False,
|
||||
"ENTRANCE_EXAMS": False,
|
||||
})
|
||||
@override_settings(ENTRANCE_EXAMS=False)
|
||||
@patch("cms.djangoapps.contentstore.utils.CourseDetails.update_from_json")
|
||||
def test_update_course_details_self_paced(self, mock_update):
|
||||
"""
|
||||
@@ -918,8 +918,8 @@ class UpdateCourseDetailsTests(ModuleStoreTestCase):
|
||||
|
||||
@patch.dict("django.conf.settings.FEATURES", {
|
||||
"ENABLE_PREREQUISITE_COURSES": False,
|
||||
"ENTRANCE_EXAMS": False,
|
||||
})
|
||||
@override_settings(ENTRANCE_EXAMS=False)
|
||||
@patch("cms.djangoapps.contentstore.utils.CourseDetails.update_from_json")
|
||||
def test_update_course_details_instructor_paced(self, mock_update):
|
||||
"""
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
"""
|
||||
CMS feature toggles.
|
||||
"""
|
||||
from edx_toggles.toggles import SettingDictToggle, WaffleFlag
|
||||
from edx_toggles.toggles import SettingToggle, WaffleFlag
|
||||
from openedx.core.djangoapps.content.search import api as search_api
|
||||
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
|
||||
|
||||
|
||||
# .. toggle_name: FEATURES['ENABLE_EXPORT_GIT']
|
||||
# .. toggle_implementation: SettingDictToggle
|
||||
# .. toggle_name: ENABLE_EXPORT_GIT
|
||||
# .. toggle_implementation: SettingToggle
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: When enabled, a "Export to Git" menu item is added to the course studio for courses that have a
|
||||
# valid "giturl" attribute. Exporting a course to git causes the course to be exported in the directory indicated by
|
||||
@@ -17,8 +17,8 @@ from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
|
||||
# existing directory.
|
||||
# .. toggle_use_cases: open_edx
|
||||
# .. toggle_creation_date: 2014-02-13
|
||||
EXPORT_GIT = SettingDictToggle(
|
||||
"FEATURES", "ENABLE_EXPORT_GIT", default=False, module_name=__name__
|
||||
EXPORT_GIT = SettingToggle(
|
||||
"ENABLE_EXPORT_GIT", default=False, module_name=__name__
|
||||
)
|
||||
|
||||
# Namespace for studio dashboard waffle flags.
|
||||
@@ -406,8 +406,8 @@ def default_enable_flexible_peer_openassessments(course_key):
|
||||
return DEFAULT_ENABLE_FLEXIBLE_PEER_OPENASSESSMENTS.is_enabled(course_key)
|
||||
|
||||
|
||||
# .. toggle_name: FEATURES['ENABLE_CONTENT_LIBRARIES']
|
||||
# .. toggle_implementation: SettingDictToggle
|
||||
# .. toggle_name: ENABLE_CONTENT_LIBRARIES
|
||||
# .. toggle_implementation: SettingToggle
|
||||
# .. toggle_default: True
|
||||
# .. toggle_description: Enables use of the legacy and v2 libraries waffle flags.
|
||||
# Note that legacy content libraries are only supported in courses using split mongo.
|
||||
@@ -416,8 +416,8 @@ def default_enable_flexible_peer_openassessments(course_key):
|
||||
# .. toggle_target_removal_date: 2025-04-09
|
||||
# .. toggle_warning: This flag is deprecated in Sumac, and will be removed in favor of the disable_legacy_libraries and
|
||||
# disable_new_libraries waffle flags.
|
||||
ENABLE_CONTENT_LIBRARIES = SettingDictToggle(
|
||||
"FEATURES", "ENABLE_CONTENT_LIBRARIES", default=True, module_name=__name__
|
||||
ENABLE_CONTENT_LIBRARIES = SettingToggle(
|
||||
"ENABLE_CONTENT_LIBRARIES", default=True, module_name=__name__
|
||||
)
|
||||
|
||||
# .. toggle_name: contentstore.new_studio_mfe.disable_legacy_libraries
|
||||
|
||||
@@ -4,9 +4,9 @@ Test module for Entrance Exams AJAX callback handler workflows
|
||||
|
||||
|
||||
import json
|
||||
from unittest.mock import patch
|
||||
|
||||
from django.conf import settings
|
||||
from django.test import override_settings
|
||||
from django.test.client import RequestFactory
|
||||
from milestones.tests.utils import MilestonesTestCaseMixin
|
||||
from opaque_keys.edx.keys import UsageKey
|
||||
@@ -30,7 +30,7 @@ from cms.djangoapps.contentstore.helpers import GRADER_TYPES
|
||||
from cms.djangoapps.contentstore.xblock_storage_handlers.create_xblock import create_xblock
|
||||
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENTRANCE_EXAMS': True})
|
||||
@override_settings(ENTRANCE_EXAMS=True)
|
||||
class EntranceExamHandlerTests(CourseTestCase, MilestonesTestCaseMixin):
|
||||
"""
|
||||
Base test class for create, save, and delete
|
||||
@@ -319,7 +319,7 @@ class EntranceExamHandlerTests(CourseTestCase, MilestonesTestCaseMixin):
|
||||
resp = create_entrance_exam(request, self.course.id, None)
|
||||
self.assertEqual(resp.status_code, 201)
|
||||
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENTRANCE_EXAMS': False})
|
||||
@override_settings(ENTRANCE_EXAMS=False)
|
||||
def test_entrance_exam_feature_flag_gating(self):
|
||||
user = UserFactory()
|
||||
user.is_staff = True
|
||||
|
||||
@@ -161,7 +161,7 @@ class UnitTestLibraries(CourseTestCase):
|
||||
self.assertEqual(get_response.status_code, 200)
|
||||
self.assertEqual(post_response.status_code, 403)
|
||||
|
||||
@mock.patch.dict('django.conf.settings.FEATURES', {'ENABLE_CONTENT_LIBRARIES': False})
|
||||
@override_settings(ENABLE_CONTENT_LIBRARIES=False)
|
||||
def test_with_libraries_disabled(self):
|
||||
"""
|
||||
The library URLs should return 404 if libraries are disabled.
|
||||
|
||||
Reference in New Issue
Block a user