From c512415703777e069af23ae4b583790b4a01d90c Mon Sep 17 00:00:00 2001 From: Asad Ali Date: Thu, 16 Jan 2025 19:05:53 +0500 Subject: [PATCH] refactor: migrate digital credentials flag to posthog (#3367) --- mitxpro/features.py | 1 + mitxpro/utils.py | 2 +- mitxpro/utils_test.py | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mitxpro/features.py b/mitxpro/features.py index 07e278480..28a77a6d5 100644 --- a/mitxpro/features.py +++ b/mitxpro/features.py @@ -1,4 +1,5 @@ """MIT xPRO features""" +DIGITAL_CREDENTIALS = "digital_credentials" ENABLE_ENTERPRISE = "enable_enterprise" ENROLLMENT_WELCOME_EMAIL = "enrollment_welcome_email" diff --git a/mitxpro/utils.py b/mitxpro/utils.py index 30fc4522c..15c1669c4 100644 --- a/mitxpro/utils.py +++ b/mitxpro/utils.py @@ -601,7 +601,7 @@ def get_js_settings(request: HttpRequest): "help_widget_enabled": settings.ZENDESK_CONFIG.get("HELP_WIDGET_ENABLED"), "help_widget_key": settings.ZENDESK_CONFIG.get("HELP_WIDGET_KEY"), }, - "digital_credentials": settings.FEATURES.get("DIGITAL_CREDENTIALS", False), + "digital_credentials": is_enabled(features.DIGITAL_CREDENTIALS, default=False), "digital_credentials_supported_runs": settings.DIGITAL_CREDENTIALS_SUPPORTED_RUNS, "is_tax_applicable": is_tax_applicable(request), "enable_enterprise": is_enabled(features.ENABLE_ENTERPRISE, default=False), diff --git a/mitxpro/utils_test.py b/mitxpro/utils_test.py index 0c702d2b6..dfecc0709 100644 --- a/mitxpro/utils_test.py +++ b/mitxpro/utils_test.py @@ -11,6 +11,7 @@ from ecommerce.api import is_tax_applicable from ecommerce.models import Order +from mitxpro import features from mitxpro.test_utils import MockResponse from mitxpro.utils import ( all_equal, @@ -463,6 +464,8 @@ def posthog_is_enabled_side_effect(*args, **kwargs): """ Side effect to return True/False for specific features while mocking posthog is_enabled. """ + if args[0] == features.DIGITAL_CREDENTIALS: # noqa: SIM103 + return True return False settings.GA_TRACKING_ID = "fake" @@ -476,7 +479,6 @@ def posthog_is_enabled_side_effect(*args, **kwargs): "HELP_WIDGET_ENABLED": False, "HELP_WIDGET_KEY": "fake_key", } - settings.FEATURES["DIGITAL_CREDENTIALS"] = True settings.DIGITAL_CREDENTIALS_SUPPORTED_RUNS = "test_run1,test_run2" mocker.patch( "mitol.olposthog.features.is_enabled", @@ -498,7 +500,7 @@ def posthog_is_enabled_side_effect(*args, **kwargs): "support_email": settings.EMAIL_SUPPORT, "site_name": settings.SITE_NAME, "zendesk_config": {"help_widget_enabled": False, "help_widget_key": "fake_key"}, - "digital_credentials": settings.FEATURES.get("DIGITAL_CREDENTIALS", False), + "digital_credentials": True, "digital_credentials_supported_runs": settings.DIGITAL_CREDENTIALS_SUPPORTED_RUNS, "is_tax_applicable": is_tax_applicable(request), "enable_enterprise": False,