Skip to content

Commit

Permalink
chore: extending the enterprise fulfillment api serializer to contain…
Browse files Browse the repository at this point in the history
… more info
  • Loading branch information
alex-sheehan-edx committed May 26, 2023
1 parent 874ebb8 commit 2a2cb36
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
6 changes: 3 additions & 3 deletions enterprise/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class EnterpriseCourseEnrollmentReadOnlySerializer(serializers.ModelSerializer):
class Meta:
model = models.EnterpriseCourseEnrollment
fields = (
'enterprise_customer_user', 'course_id'
'enterprise_customer_user', 'course_id', 'modified',
)


Expand Down Expand Up @@ -417,7 +417,7 @@ class LearnerCreditEnterpriseCourseEnrollmentReadOnlySerializer(serializers.Mode
class Meta:
model = models.LearnerCreditEnterpriseCourseEnrollment
fields = (
'enterprise_course_enrollment', 'transaction_id'
'enterprise_course_enrollment', 'transaction_id', 'uuid',
)


Expand All @@ -431,7 +431,7 @@ class LicensedEnterpriseCourseEnrollmentReadOnlySerializer(serializers.ModelSeri
class Meta:
model = models.LicensedEnterpriseCourseEnrollment
fields = (
'enterprise_course_enrollment', 'license_uuid'
'enterprise_course_enrollment', 'license_uuid', 'uuid',
)


Expand Down
2 changes: 1 addition & 1 deletion enterprise/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def enroll_learners_in_courses(self, request, pk):
"""
Creates a set of enterprise enrollments for specified learners by bulk enrolling them in provided courses.
This endpoint is not transactional, in that any one or more failures will not affect other successful
enrollments smade within the same request.
enrollments made within the same request.
Parameters:
enrollments_info (list of dicts): an array of dictionaries, each containing the necessary information to
Expand Down
41 changes: 30 additions & 11 deletions tests/test_enterprise/api/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1232,10 +1232,12 @@ class TestEnterpriseCustomerViewSet(BaseTestEnterpriseAPIViews):
[{
'enterprise_customer_user__id': 1,
'course_id': 'course-v1:edX+DemoX+DemoCourse',
'modified': '2021-10-20T19:01:31Z',
}],
[{
'enterprise_customer_user': 1,
'course_id': 'course-v1:edX+DemoX+DemoCourse',
'modified': '2021-10-20T19:01:31Z',
}],
),
(
Expand Down Expand Up @@ -3399,18 +3401,24 @@ def test_requested_recently_unenrolled_subsidy_fulfillment(self):
OrderedDict([
('enterprise_course_enrollment', OrderedDict([
('enterprise_customer_user', lc_ent_user_1),
('course_id', self.learner_credit_course_enrollment.enterprise_course_enrollment.course_id)
('course_id', self.learner_credit_course_enrollment.enterprise_course_enrollment.course_id),
('modified', self.learner_credit_course_enrollment.modified.strftime("%Y-%m-%dT%H:%M:%SZ")),
])),
('transaction_id', self.learner_credit_course_enrollment.transaction_id)
('transaction_id', self.learner_credit_course_enrollment.transaction_id),
('uuid', str(self.learner_credit_course_enrollment.uuid)),
]),
OrderedDict([
('enterprise_course_enrollment', OrderedDict(
[
('enterprise_customer_user', lc_ent_user_2),
('course_id', second_lc_enrollment.enterprise_course_enrollment.course_id)
('course_id', second_lc_enrollment.enterprise_course_enrollment.course_id),
('modified', second_lc_enrollment.enterprise_course_enrollment.modified.strftime(
"%Y-%m-%dT%H:%M:%SZ"
)),
]
)),
('transaction_id', second_lc_enrollment.transaction_id)
('transaction_id', second_lc_enrollment.transaction_id),
('uuid', str(second_lc_enrollment.uuid)),
])
]

Expand Down Expand Up @@ -3440,14 +3448,17 @@ def test_recently_unenrolled_fulfillment_endpoint_can_filter_for_modified_after(
)

ent_user = old_learner_credit_enrollment.enterprise_course_enrollment.enterprise_customer_user.id

assert response.data == [
OrderedDict([
('enterprise_course_enrollment', OrderedDict([
('enterprise_customer_user', ent_user),
('course_id', old_learner_credit_enrollment.enterprise_course_enrollment.course_id)
('course_id', old_learner_credit_enrollment.enterprise_course_enrollment.course_id),
('modified', old_learner_credit_enrollment.enterprise_course_enrollment.modified.strftime(
"%Y-%m-%dT%H:%M:%SZ"
)),
])),
('transaction_id', old_learner_credit_enrollment.transaction_id)
('transaction_id', old_learner_credit_enrollment.transaction_id),
('uuid', str(old_learner_credit_enrollment.uuid)),
]),
]

Expand All @@ -3466,9 +3477,13 @@ def test_recently_unenrolled_licensed_fulfillment_object(self):
OrderedDict([
('enterprise_course_enrollment', OrderedDict([
('enterprise_customer_user', ent_user),
('course_id', self.licensed_course_enrollment.enterprise_course_enrollment.course_id)
('course_id', self.licensed_course_enrollment.enterprise_course_enrollment.course_id),
('modified', self.licensed_course_enrollment.enterprise_course_enrollment.modified.strftime(
"%Y-%m-%dT%H:%M:%SZ"
)),
])),
('license_uuid', str(self.licensed_course_enrollment.license_uuid))
('license_uuid', str(self.licensed_course_enrollment.license_uuid)),
('uuid', str(self.licensed_course_enrollment.uuid)),
]),
]

Expand All @@ -3486,7 +3501,9 @@ def test_successful_retrieve_licensed_enrollment(self):
'enterprise_course_enrollment': {
'enterprise_customer_user': self.enterprise_user.id,
'course_id': self.enterprise_course_enrollment.course_id,
}
'modified': self.enterprise_course_enrollment.modified.strftime("%Y-%m-%dT%H:%M:%SZ"),
},
'uuid': str(self.licensed_course_enrollment.uuid),
}

def test_successful_retrieve_learner_credit_enrollment(self):
Expand All @@ -3504,7 +3521,9 @@ def test_successful_retrieve_learner_credit_enrollment(self):
'enterprise_course_enrollment': {
'enterprise_customer_user': self.enterprise_user.id,
'course_id': self.enterprise_course_enrollment.course_id,
}
'modified': self.enterprise_course_enrollment.modified.strftime("%Y-%m-%dT%H:%M:%SZ"),
},
'uuid': str(self.learner_credit_course_enrollment.uuid),
}

def test_retrieve_nonexistent_enrollment(self):
Expand Down

0 comments on commit 2a2cb36

Please sign in to comment.