diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 0ed5747b0..0239f9959 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -17,6 +17,10 @@ Unreleased
----------
* nothing unreleased
+[4.30.1]
+--------
+* fix: serialize best_mode_for_course_run field in DefaultEnterpriseEnrollmentIntentionSerializer.
+
[4.30.0]
--------
* feat: REST APIs for default-enterprise-enrollment-intentions
diff --git a/enterprise/__init__.py b/enterprise/__init__.py
index 47ad52738..c39375715 100644
--- a/enterprise/__init__.py
+++ b/enterprise/__init__.py
@@ -2,4 +2,4 @@
Your project description goes here.
"""
-__version__ = "4.30.0"
+__version__ = "4.30.1"
diff --git a/enterprise/api/v1/serializers.py b/enterprise/api/v1/serializers.py
index 4c62311ab..0646b3b4f 100644
--- a/enterprise/api/v1/serializers.py
+++ b/enterprise/api/v1/serializers.py
@@ -1915,6 +1915,7 @@ class Meta:
'course_key',
'course_run_key',
'is_course_run_enrollable',
+ 'best_mode_for_course_run',
'applicable_enterprise_catalog_uuids',
'course_run_normalized_metadata',
'created',
@@ -1942,6 +1943,12 @@ def get_course_run_normalized_metadata(self, obj):
def get_applicable_enterprise_catalog_uuids(self, obj):
return obj.applicable_enterprise_catalog_uuids
+ def get_best_mode_for_course_run(self, obj):
+ """
+ Get the best course mode for the course run.
+ """
+ return obj.best_mode_for_course_run
+
class DefaultEnterpriseEnrollmentIntentionWithEnrollmentStateSerializer(DefaultEnterpriseEnrollmentIntentionSerializer):
"""
diff --git a/test_utils/fake_catalog_api.py b/test_utils/fake_catalog_api.py
index a8ddeb61d..a2df46c25 100644
--- a/test_utils/fake_catalog_api.py
+++ b/test_utils/fake_catalog_api.py
@@ -9,6 +9,7 @@
from unittest import mock
from test_utils import FAKE_UUIDS
+from tests.test_enterprise.api.constants import AUDIT_COURSE_MODE, VERIFIED_COURSE_MODE
FAKE_URL = 'https://fake.url'
@@ -26,7 +27,7 @@
'marketing_url': 'course/demo-course?utm_=test_enterprise&utm_medium=enterprise',
'seats': [
{
- 'type': 'audit',
+ 'type': AUDIT_COURSE_MODE,
'price': '0.00',
'currency': 'USD',
'upgrade_deadline': None,
@@ -35,7 +36,7 @@
'sku': '68EFFFF'
},
{
- 'type': 'verified',
+ 'type': VERIFIED_COURSE_MODE,
'price': '149.00',
'currency': 'USD',
'upgrade_deadline': '2018-08-03T16:44:26.595896Z',
@@ -50,7 +51,7 @@
'enrollment_end': None,
'enrollment_url': FAKE_URL,
'pacing_type': 'instructor_paced',
- 'type': 'verified',
+ 'type': VERIFIED_COURSE_MODE,
'status': 'published',
'course': 'edX+DemoX',
'full_description': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
@@ -110,7 +111,7 @@
'marketing_url': 'course/demo-course?utm_=test_enterprise&utm_medium=enterprise',
'seats': [
{
- 'type': 'audit',
+ 'type': AUDIT_COURSE_MODE,
'price': 0,
'currency': 'USD',
'upgrade_deadline': None,
@@ -119,7 +120,7 @@
'sku': '68EFFFF'
},
{
- 'type': 'verified',
+ 'type': VERIFIED_COURSE_MODE,
'price': 149,
'currency': 'USD',
'upgrade_deadline': '2018-08-03T16:44:26.595896Z',
@@ -135,7 +136,7 @@
'enrollment_end': None,
'enrollment_url': FAKE_URL,
'pacing_type': 'instructor_paced',
- 'type': 'verified',
+ 'type': VERIFIED_COURSE_MODE,
'status': 'published',
"is_enrollable": True,
"is_marketable": True,
@@ -403,7 +404,7 @@
"staff": [],
"credit_redemption_overview": "This is a test Program.",
"applicable_seat_types": [
- "audit"
+ AUDIT_COURSE_MODE
],
}
@@ -567,7 +568,7 @@
"min_hours_effort_per_week": 5,
"max_hours_effort_per_week": 10,
"applicable_seat_types": [
- "verified",
+ VERIFIED_COURSE_MODE,
"professional",
"credit",
],
@@ -598,7 +599,7 @@
}
},
"applicable_seat_types": [
- "verified",
+ VERIFIED_COURSE_MODE,
"professional",
"credit"
],
@@ -623,7 +624,7 @@
"credit_hours": None
},
{
- "type": "audit",
+ "type": AUDIT_COURSE_MODE,
"price": "0.00",
"currency": "USD",
"upgrade_deadline": None,
@@ -669,7 +670,7 @@
"credit_hours": None
},
{
- "type": "audit",
+ "type": AUDIT_COURSE_MODE,
"price": "0.00",
"currency": "AED",
"upgrade_deadline": None,
@@ -847,14 +848,14 @@
"enrollment_start": None,
"enrollment_end": None,
"pacing_type": "instructor_paced",
- "type": "audit",
+ "type": AUDIT_COURSE_MODE,
"course": "edX+DemoX",
"full_description": None,
"announcement": None,
"video": None,
"seats": [
{
- "type": "audit",
+ "type": AUDIT_COURSE_MODE,
"price": "0.00",
"currency": "USD",
"upgrade_deadline": None,
@@ -1103,8 +1104,8 @@
"course_runs": [],
"full_description": None,
"seat_types": [
- "audit",
- "verified"
+ AUDIT_COURSE_MODE,
+ VERIFIED_COURSE_MODE,
],
"mobile_available": False,
"end": None,
@@ -1122,7 +1123,7 @@
"staff_uuids": [],
"language": None,
"number": "DemoX",
- "type": "verified",
+ "type": VERIFIED_COURSE_MODE,
"key": "course-v1:edX+DemoX+Demo_Course",
"org": "edX",
"level_type": None,
@@ -1375,7 +1376,7 @@
"course_runs": [
{
"enrollment_end": None,
- "enrollment_mode": "verified",
+ "enrollment_mode": VERIFIED_COURSE_MODE,
"key": "course-v1:edX+DemoX+Demo_Course",
"enrollment_start": None,
"pacing_type": "instructor_paced",
@@ -1542,7 +1543,7 @@ def create_course_run_dict(start="2014-10-14T13:11:03Z", end="3000-10-13T13:11:0
"status": status,
"enrollment_start": enrollment_start,
"enrollment_end": enrollment_end,
- "seats": [{"type": "verified", "upgrade_deadline": upgrade_deadline}],
+ "seats": [{"type": VERIFIED_COURSE_MODE, "upgrade_deadline": upgrade_deadline}],
"availability": availability,
"weeks_to_complete": weeks_to_complete,
"uuid": uuid,
diff --git a/tests/test_enterprise/api/constants.py b/tests/test_enterprise/api/constants.py
index e7cf071dc..558d7c45a 100644
--- a/tests/test_enterprise/api/constants.py
+++ b/tests/test_enterprise/api/constants.py
@@ -11,3 +11,7 @@
(' ', "https://idp1.example.com"), # pylint: disable=line-too-long
('', "https://example.com") # pylint: disable=line-too-long
]
+
+# Course Modes
+VERIFIED_COURSE_MODE = 'verified'
+AUDIT_COURSE_MODE = 'audit'
diff --git a/tests/test_enterprise/api/test_views.py b/tests/test_enterprise/api/test_views.py
index 9dac6445a..c2e2a126a 100644
--- a/tests/test_enterprise/api/test_views.py
+++ b/tests/test_enterprise/api/test_views.py
@@ -111,7 +111,7 @@
)
from test_utils.fake_enterprise_api import get_default_branding_object
-from .constants import FAKE_SSO_METADATA_XML_WITH_ENTITY_ID
+from .constants import AUDIT_COURSE_MODE, FAKE_SSO_METADATA_XML_WITH_ENTITY_ID, VERIFIED_COURSE_MODE
Application = get_application_model()
fake = Faker()
@@ -173,8 +173,6 @@
DEFAULT_ENTERPRISE_ENROLLMENT_INTENTION_LEARNER_STATUS_ENDPOINT = reverse(
'default-enterprise-enrollment-intentions-learner-status'
)
-VERIFIED_COURSE_MODE = 'verified'
-AUDIT_COURSE_MODE = 'audit'
def get_default_enterprise_enrollment_intention_detail_endpoint(enrollment_intention_uuid=None):
@@ -9776,6 +9774,7 @@ def get_default_enrollment_intention_with_learner_enrollment_state(self, enrollm
**kwargs: Additional parameters to customize the response.
- applicable_enterprise_catalog_uuids: List of applicable enterprise catalog UUIDs.
- is_course_run_enrollable: Boolean indicating if the course run is enrollable.
+ - best_mode_for_course_run: The best mode for the course run (e.g., "verified", "audit").
- has_existing_enrollment: Boolean indicating if there is an existing enrollment.
- is_existing_enrollment_active: Boolean indicating if the existing enrollment is
active, or None if no existing enrollment.
@@ -9789,6 +9788,7 @@ def get_default_enrollment_intention_with_learner_enrollment_state(self, enrollm
'course_key': enrollment_intention.course_key,
'course_run_key': enrollment_intention.course_run_key,
'is_course_run_enrollable': kwargs.get('is_course_run_enrollable', True),
+ 'best_mode_for_course_run': kwargs.get('best_mode_for_course_run', VERIFIED_COURSE_MODE),
'applicable_enterprise_catalog_uuids': kwargs.get(
'applicable_enterprise_catalog_uuids',
[fake_catalog_api.FAKE_CATALOG_RESULT.get('uuid')],
@@ -10258,10 +10258,8 @@ def test_default_enrollment_intentions_learner_status_already_enrolled_active_au
self.set_jwt_cookie(ENTERPRISE_LEARNER_ROLE, str(self.enterprise_customer.uuid))
enrollment_intention = self.create_mock_default_enterprise_enrollment_intention(mock_catalog_api_client)
- if has_audit_mode_only:
- mock_get_best_mode_from_course_key.return_value = AUDIT_COURSE_MODE
- else:
- mock_get_best_mode_from_course_key.return_value = VERIFIED_COURSE_MODE
+ best_mode_for_course_run = AUDIT_COURSE_MODE if has_audit_mode_only else VERIFIED_COURSE_MODE
+ mock_get_best_mode_from_course_key.return_value = best_mode_for_course_run
enterprise_customer_user = factories.EnterpriseCustomerUserFactory(
user_id=self.user.id,
@@ -10293,6 +10291,7 @@ def test_default_enrollment_intentions_learner_status_already_enrolled_active_au
has_existing_enrollment=True,
is_existing_enrollment_active=True,
is_existing_enrollment_audit=True,
+ best_mode_for_course_run=best_mode_for_course_run,
)
if has_audit_mode_only: