-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow course entitlements REST API to be filtered on course_uuid #32305
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -672,6 +672,34 @@ def test_get_expired_entitlement_by_uuid(self): | |
results = response.data | ||
assert results.get('expired_at') | ||
|
||
def test_entitlements_filter_on_course_uuid(self): | ||
""" | ||
Verify that courses filtered properly on list of course_uuids. | ||
""" | ||
entitlements = CourseEntitlementFactory.create_batch(5, user=self.user) | ||
course_uuids_to_filter_on = { | ||
str(entitlement.course_uuid) | ||
for entitlement in entitlements[0:3] | ||
} | ||
# Create a 2nd entitlement for one of the ones to filter on | ||
CourseEntitlementFactory.create(user=self.user, course_uuid=str(entitlements[0].course_uuid)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not get it. Could you please elaborate on why are we creating another entry with the same course UUID? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wanted the test set to seem more realistic, because in the wild we can potentially encounter a response that has entitlements with the same course_uuid |
||
|
||
url = reverse('entitlements_api:v1:entitlements-list') | ||
url += f'?user={self.user.username}' | ||
url += f'&course_uuid={",".join(course_uuids_to_filter_on)}' | ||
|
||
response = self.client.get( | ||
url, | ||
content_type='application/json', | ||
) | ||
assert response.status_code == 200 | ||
|
||
results = response.data | ||
assert results['count'] == 4 | ||
actual_course_uuids = {entitlement['course_uuid'] for entitlement in results['results']} | ||
assert actual_course_uuids == course_uuids_to_filter_on | ||
assert len(actual_course_uuids) == 3 | ||
shafqatfarhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def test_delete_and_revoke_entitlement(self): | ||
course_entitlement = CourseEntitlementFactory.create() | ||
url = reverse(self.ENTITLEMENTS_DETAILS_PATH, args=[str(course_entitlement.uuid)]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will query params character length be an issue if there is a large courseUUID list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potentially, yes