Skip to content

Commit

Permalink
refactor: migrate digital credentials flag to posthog (#3367)
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 authored Jan 16, 2025
1 parent fdeab37 commit c512415
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions mitxpro/features.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""MIT xPRO features"""

DIGITAL_CREDENTIALS = "digital_credentials"
ENABLE_ENTERPRISE = "enable_enterprise"
ENROLLMENT_WELCOME_EMAIL = "enrollment_welcome_email"
2 changes: 1 addition & 1 deletion mitxpro/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 4 additions & 2 deletions mitxpro/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"
Expand All @@ -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",
Expand All @@ -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,
Expand Down

0 comments on commit c512415

Please sign in to comment.