Skip to content
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: add parent_course query parameter to basic content-metadata endpoint #1026

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

pwnage101
Copy link
Contributor

ENT-9840

Comment on lines 82 to 83
# If ``?parent_course=true`` was passed, exclude course runs.
if self.request.query_params.get('parent_course', False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just "exclude_course_runs" for the parameter name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exclude_course_runs suggests the only behavior change is that course runs are excluded. But that is untrue for retrieve(), in which case requested course runs are converted to courses (rather than 404 which is what I'd expect based on the name `exclude_course_runs).

That said, I'm still open to alternative names. Maybe "coerce_to_parent_course"?

enterprise_catalog/apps/api/v1/views/content_metadata.py Outdated Show resolved Hide resolved
@pwnage101 pwnage101 force-pushed the pwnage101/ENT-9840 branch 2 times, most recently from b61c41d to 4118412 Compare January 22, 2025 01:03
@pwnage101 pwnage101 marked this pull request as ready for review January 22, 2025 01:07
Copy link
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work. Approving to unblock. Very cool implementation using the test helper ddt_cross_product. I learned something new today!

Comment on lines +2222 to +2284
@ddt.data(*ddt_cross_product(
[
{'request_content_type': COURSE, 'coerce_to_parent_course': False, 'expect_content_type': COURSE},
{'request_content_type': COURSE, 'coerce_to_parent_course': True, 'expect_content_type': COURSE},
{'request_content_type': COURSE_RUN, 'coerce_to_parent_course': False, 'expect_content_type': COURSE_RUN},
{'request_content_type': COURSE_RUN, 'coerce_to_parent_course': True, 'expect_content_type': COURSE},
],
# Repeat ever test above given different types of identifier input types.
[
{'request_by_field': 'id'},
{'request_by_field': 'content_key'},
{'request_by_field': 'content_uuid'},
],
))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool implementation, if I am understanding correctly, this ends up being 12 test cases total?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, 12!

@pwnage101 pwnage101 merged commit 11cd73c into master Jan 22, 2025
6 checks passed
@pwnage101 pwnage101 deleted the pwnage101/ENT-9840 branch January 22, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants