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:
@@ -3,7 +3,7 @@ Utility library for working with the edx-milestones app
|
||||
"""
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext as _
|
||||
from edx_toggles.toggles import SettingDictToggle
|
||||
from edx_toggles.toggles import SettingToggle
|
||||
from milestones import api as milestones_api
|
||||
from milestones.exceptions import InvalidMilestoneRelationshipTypeException, InvalidUserException
|
||||
from milestones.models import MilestoneRelationshipType
|
||||
@@ -23,15 +23,15 @@ NAMESPACE_CHOICES = {
|
||||
REQUEST_CACHE_NAME = "milestones"
|
||||
|
||||
# TODO this should be moved to edx/edx-milestones
|
||||
# .. toggle_name: FEATURES['MILESTONES_APP']
|
||||
# .. toggle_implementation: SettingDictToggle
|
||||
# .. toggle_name: MILESTONES_APP
|
||||
# .. toggle_implementation: SettingToggle
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Enable the milestones application, which manages significant Course and/or Student events in
|
||||
# the Open edX platform. (see https://github.com/openedx/edx-milestones) Note that this feature is required to enable
|
||||
# course pre-requisites.
|
||||
# .. toggle_use_cases: open_edx
|
||||
# .. toggle_creation_date: 2014-11-21
|
||||
ENABLE_MILESTONES_APP = SettingDictToggle("FEATURES", "MILESTONES_APP", default=False, module_name=__name__)
|
||||
ENABLE_MILESTONES_APP = SettingToggle("MILESTONES_APP", default=False, module_name=__name__)
|
||||
|
||||
|
||||
def get_namespace_choices():
|
||||
|
||||
@@ -5,8 +5,8 @@ from unittest.mock import patch
|
||||
|
||||
import ddt
|
||||
import pytest
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.test import override_settings
|
||||
from milestones import api as milestones_api
|
||||
from milestones.exceptions import InvalidCourseKeyException, InvalidUserException
|
||||
from milestones.models import MilestoneRelationshipType
|
||||
@@ -16,7 +16,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase # lint-a
|
||||
from xmodule.modulestore.tests.factories import CourseFactory # lint-amnesty, pylint: disable=wrong-import-order
|
||||
|
||||
|
||||
@patch.dict(settings.FEATURES, {'MILESTONES_APP': False})
|
||||
@override_settings(MILESTONES_APP=False)
|
||||
@ddt.ddt
|
||||
class MilestonesHelpersTestCase(ModuleStoreTestCase):
|
||||
"""
|
||||
@@ -61,8 +61,7 @@ class MilestonesHelpersTestCase(ModuleStoreTestCase):
|
||||
|
||||
with patch.dict("django.conf.settings.FEATURES", {
|
||||
'ENABLE_PREREQUISITE_COURSES': feature_flags[0],
|
||||
'MILESTONES_APP': feature_flags[1]
|
||||
}):
|
||||
}), override_settings(MILESTONES_APP=feature_flags[1]):
|
||||
assert feature_flags[2] == milestones_helpers.is_prerequisite_courses_enabled()
|
||||
|
||||
def test_add_milestone_returns_none_when_app_disabled(self):
|
||||
@@ -123,7 +122,7 @@ class MilestonesHelpersTestCase(ModuleStoreTestCase):
|
||||
response = milestones_helpers.get_service()
|
||||
assert response is None
|
||||
|
||||
@patch.dict(settings.FEATURES, {'MILESTONES_APP': True})
|
||||
@override_settings(MILESTONES_APP=True)
|
||||
def test_any_unfulfilled_milestones(self):
|
||||
"""
|
||||
Tests any_unfulfilled_milestones for invalid arguments with the app enabled.
|
||||
@@ -137,7 +136,7 @@ class MilestonesHelpersTestCase(ModuleStoreTestCase):
|
||||
with pytest.raises(InvalidUserException):
|
||||
milestones_helpers.any_unfulfilled_milestones(self.course.id, None)
|
||||
|
||||
@patch.dict(settings.FEATURES, {'MILESTONES_APP': True})
|
||||
@override_settings(MILESTONES_APP=True)
|
||||
def test_get_required_content_with_anonymous_user(self):
|
||||
course = CourseFactory()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user