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 filter to modify the courserun data for externally hosted c… #111

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ Change Log
Unreleased
----------

[1.6.0] - 2023-08-18
--------------------

Added
~~~~~

* CourseRunAPIRenderStarted filter added which can be used to modify the courserun data for B2C dashboard rendering process.


[1.5.0] - 2023-07-19
--------------------

Expand Down
2 changes: 1 addition & 1 deletion openedx_filters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"""
from openedx_filters.filters import *

__version__ = "1.5.0"
__version__ = "1.6.0"
19 changes: 19 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,25 @@ def run_filter(cls, course_key, serialized_enrollment):
return data.get("course_key"), data.get("serialized_enrollment")


class CourseRunAPIRenderStarted(OpenEdxPublicFilter):
"""
Custom class used to create filters for course run data.
"""

filter_type = "org.openedx.learning.home.courserun.api.rendered.started.v1"

@classmethod
def run_filter(cls, serialized_courserun):
"""
Execute a filter with the specified signature.

Arguments:
serialized_courserun (dict): courserun data
"""
data = super().run_pipeline(serialized_courserun=serialized_courserun)
return data.get("serialized_courserun")


class InstructorDashboardRenderStarted(OpenEdxPublicFilter):
"""
Custom class used to create instructor dashboard filters and its custom methods.
Expand Down
15 changes: 15 additions & 0 deletions openedx_filters/learning/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
CourseEnrollmentQuerysetRequested,
CourseEnrollmentStarted,
CourseHomeUrlCreationStarted,
CourseRunAPIRenderStarted,
CourseUnenrollmentStarted,
DashboardRenderStarted,
InstructorDashboardRenderStarted,
Expand Down Expand Up @@ -619,3 +620,17 @@ def test_course_enrollment_api_render_started(self):
result = CourseEnrollmentAPIRenderStarted.run_filter(course_key, serialized_enrollment)

self.assertTupleEqual((course_key, serialized_enrollment,), result)

def test_course_run_api_render_started(self):
"""
Test CourseRunAPIRenderStarted filter behavior under normal conditions.

Expected behavior:
- The filter must have the signature specified.
- The filter should return serialized_courserun.
"""
serialized_courserun = Mock()

result = CourseRunAPIRenderStarted.run_filter(serialized_courserun)

self.assertEqual(serialized_courserun, result)