refactor: remove per-page waffle flag in favour of global one

This commit is contained in:
Andrii
2025-06-23 19:08:59 +03:00
committed by Sarina Canelake
parent 256511e196
commit 94ce8fa147
2 changed files with 9 additions and 37 deletions

View File

@@ -2,11 +2,10 @@
Tests for toggles, where there is logic beyond enable/disable.
"""
from unittest.mock import patch
import ddt
from django.test import TestCase
from django.test import override_settings, TestCase
from lms.djangoapps.branding.toggles import use_new_catalog_page
from lms.djangoapps.branding.toggles import use_catalog_mfe
@ddt.ddt
@@ -16,15 +15,9 @@ class TestBrandingToggles(TestCase):
"""
@ddt.data(True, False)
@patch("lms.djangoapps.branding.toggles.ENABLE_NEW_CATALOG_PAGE")
def test_use_new_catalog_page_enabled(
self, is_waffle_enabled, mock_enable_new_catalog_page
):
# Given legacy catalog feature is / not enabled
mock_enable_new_catalog_page.is_enabled.return_value = is_waffle_enabled
# When I check if the feature is enabled
should_use_new_catalog_page = use_new_catalog_page()
# Then I respects waffle setting.
self.assertEqual(should_use_new_catalog_page, is_waffle_enabled)
def test_use_catalog_mfe(self, enabled):
"""
Test the use_catalog_mfe toggle.
"""
with override_settings(FEATURES={'ENABLE_CATALOG_MICROFRONTEND': enabled}):
assert use_catalog_mfe() == enabled

View File

@@ -2,35 +2,14 @@
Configuration for features of Branding
"""
from django.conf import settings
from edx_toggles.toggles import WaffleFlag
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
# Namespace for Waffle flags related to branding
WAFFLE_FLAG_NAMESPACE = "new_catalog_mfe"
def catalog_mfe_enabled():
def use_catalog_mfe():
"""
Determine if Catalog MFE is enabled, replacing student_dashboard
"""
return configuration_helpers.get_value(
'ENABLE_CATALOG_MICROFRONTEND', settings.FEATURES.get('ENABLE_CATALOG_MICROFRONTEND')
)
# .. toggle_name: new_catalog_mfe.use_new_catalog_page
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Set to True to enable the new catalog page.
# .. toggle_creation_date: 2025-05-15
# .. toggle_target_removal_date: 2025-11-01
# .. toggle_use_cases: open_edx
ENABLE_NEW_CATALOG_PAGE = WaffleFlag(f'{WAFFLE_FLAG_NAMESPACE}.use_new_catalog_page', __name__)
def use_new_catalog_page():
"""
Returns a boolean if new catalog page should be used.
"""
return ENABLE_NEW_CATALOG_PAGE.is_enabled()