ENT-201: Add support for course run key in catalog contains endpoint#721
Conversation
|
@clintonb Please review this PR and let me know your thoughts on whether we still need the PR ENT-211 add aggregate course key? Our base requirement was to validate if a course run in the basket is available for a catalog. |
clintonb
left a comment
There was a problem hiding this comment.
This will work, but it would be nice to properly define the course key in the opaque-keys library.
| assert response.data['results'] == self.serialize_catalog_course(courses, many=True) | ||
|
|
||
| def test_contains(self): | ||
| """ Verify the endpoint returns a filtered list of courses contained in the catalog. """ |
There was a problem hiding this comment.
This change is not necessary.
There was a problem hiding this comment.
Also, split this into two separate test cases, or use ddt to achieve a similar result.
|
|
||
| if course_run_ids: | ||
| course_run_ids = course_run_ids.split(',') | ||
| course_runs = CourseRun.search(catalog.query).filter(key__in=course_run_ids).values_list('key', flat=True) |
There was a problem hiding this comment.
Move this to a method on the Catalog model, similar to Catalog.contains().
8d77bdb to
5e4aaab
Compare
|
@clintonb Please have another look |
| self.assertEqual(catalog.query, query) | ||
| self.assertListEqual(list(catalog.viewers), [viewer]) | ||
|
|
||
| def _assert_catalog_contains(self, catalog_contains_query_string, course_key): |
There was a problem hiding this comment.
- Call
catalog_contains_query_stringquery_string_kwargs, which should be adict. - Add
query_string = urllib.parse.urlencode(query_string_kwargs)to de-dupe.
| """ Verify the method returns a mapping of course run IDs to booleans. """ | ||
| partner = PartnerFactory() | ||
| course_run = CourseRunFactory(course__partner=partner, course=self.course) | ||
| uncontained_course = CourseFactory(key='d/e/f', title='ABDEF') |
There was a problem hiding this comment.
This line is not necessary.
| def test_contains_course_runs(self): | ||
| """ Verify the method returns a mapping of course run IDs to booleans. """ | ||
| partner = PartnerFactory() | ||
| course_run = CourseRunFactory(course__partner=partner, course=self.course) |
There was a problem hiding this comment.
course__partner is never used since you pass course.
| partner = PartnerFactory() | ||
| course_run = CourseRunFactory(course__partner=partner, course=self.course) | ||
| uncontained_course = CourseFactory(key='d/e/f', title='ABDEF') | ||
| uncontained_course_run = CourseRunFactory(course__partner=partner, course=uncontained_course) |
There was a problem hiding this comment.
uncontained_course_run = CourseRunFactory(title_override='ABD')
5f8488c to
5a7633d
Compare
|
@clintonb thanks for the valuable feedback. I have addressed your suggestions. |
|
Thanks for taking care of this @zubair-arbi -- LGTM 👍 |
5a7633d to
6193d0a
Compare
ENT-201
@saleem-latif @asadiqbal08 @mattdrayer @clintonb @cpennington
Update the endpoint
containsofCatalogViewSetto accept a new optional parametercourse_run_id. This new parameter will be used for validating if the course run keys of the formatorg/course/runorcourse-v1:org+course+runexists in a catalog.For example in
Ecomwe can use this endpoint like this:Related PR: ENT-211 add aggregate course key