Skip to content

Commit

Permalink
feat: Implement IDV URL Filters (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilee2u authored Sep 23, 2024
1 parent fbfc4c2 commit 809bc38
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ Unreleased
----------
* Configuration for automatic filters docs generation.

[1.10.0] - 2024-09-20
--------------------

Added
~~~~~

* IDVPageURLRequested filter added which can be used to modify the URL for the ID verification process.

[1.9.0] - 2024-06-14
--------------------

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.9.0"
__version__ = "1.10.0"
19 changes: 19 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,3 +779,22 @@ def run_filter(cls, context: dict, template_name: str):
"""
data = super().run_pipeline(context=context, template_name=template_name, )
return data.get("context"), data.get("template_name")


class IDVPageURLRequested(OpenEdxPublicFilter):
"""
Custom class used to create filters to act on ID verification page URL requests.
"""

filter_type = "org.openedx.learning.idv.page.url.requested.v1"

@classmethod
def run_filter(cls, url: str):
"""
Execute a filter with the specified signature.
Arguments:
url (str): The url for the ID verification page to be modified.
"""
data = super().run_pipeline(url=url)
return data.get("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 @@ -20,6 +20,7 @@
CourseRunAPIRenderStarted,
CourseUnenrollmentStarted,
DashboardRenderStarted,
IDVPageURLRequested,
InstructorDashboardRenderStarted,
ORASubmissionViewRenderStarted,
RenderXBlockStarted,
Expand Down Expand Up @@ -728,3 +729,26 @@ def test_course_run_api_render_started(self):
result = CourseRunAPIRenderStarted.run_filter(serialized_courserun)

self.assertEqual(serialized_courserun, result)


class TestIDVFilters(TestCase):
"""
Test class to verify standard behavior of the ID verification filters.
You'll find test suites for:
- IDVPageURLRequested
"""

def test_idv_page_url_requested(self):
"""
Test IDVPageURLRequested filter behavior under normal conditions.
Expected behavior:
- The filter must have the signature specified.
- The filter should return the url.
"""
url = Mock()

result = IDVPageURLRequested.run_filter(url)

self.assertEqual(url, result)

0 comments on commit 809bc38

Please sign in to comment.