Skip to content

Commit

Permalink
feat: Added filter for modifying the course home url for externally h…
Browse files Browse the repository at this point in the history
…osted courses
  • Loading branch information
IrfanUddinAhmad authored and ormsbee committed May 25, 2023
1 parent eef893d commit 74ac9e3
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ Change Log
Unreleased
----------
[1.3.0] - 2023-05-25
--------------------

Added
~~~~~

* CourseHomeUrlCreationStarted filter added which can be used to modify the course_home_url for externally hosted courses.

[1.2.0] - 2023-03-01
--------------------

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.2.0"
__version__ = "1.3.0"
20 changes: 20 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,3 +569,23 @@ def run_filter(cls, block, fragment, context, view):
"""
data = super().run_pipeline(block=block, fragment=fragment, context=context, view=view)
return data.get("block"), data.get("fragment"), data.get("context"), data.get("view")


class CourseHomeUrlCreationStarted(OpenEdxPublicFilter):
"""
Custom class used to create filters to act on course home url creation.
"""

filter_type = "org.openedx.learning.course.homepage.url.creation.started.v1"

@classmethod
def run_filter(cls, course_key, course_home_url):
"""
Execute a filter with the specified signature.
Arguments:
course_key (CourseKey): The course key for which the home url is being requested.
course_home_url (String): The url string for the course home
"""
data = super().run_pipeline(course_key=course_key, course_home_url=course_home_url)
return data.get("course_key"), data.get("course_home_url")
24 changes: 24 additions & 0 deletions openedx_filters/learning/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
CourseAboutRenderStarted,
CourseEnrollmentQuerysetRequested,
CourseEnrollmentStarted,
CourseHomeUrlCreationStarted,
CourseUnenrollmentStarted,
DashboardRenderStarted,
StudentLoginRequested,
Expand Down Expand Up @@ -544,3 +545,26 @@ def test_cohort_assignment_requested(self):
result = CohortAssignmentRequested.run_filter(user, target_cohort)

self.assertTupleEqual((user, target_cohort,), result)


class TestFederatedContentFilters(TestCase):
"""
Test class to verify standard behavior of the federated content filters.
You'll find test suites for:
- CourseHomeUrlCreationStarted
"""

def test_course_homeurl_creation_started(self):
"""
Test CourseHomeUrlCreationStarted filter behavior under normal conditions.
Expected behavior:
- The filter must have the signature specified.
- The filter should return course_key and course_home_url in that order.
"""
course_key, course_home_url = Mock(), Mock()

result = CourseHomeUrlCreationStarted.run_filter(course_key, course_home_url)

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

0 comments on commit 74ac9e3

Please sign in to comment.