Skip to content

Commit

Permalink
feat: Implement IDV URL Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ilee2u committed Sep 10, 2024
1 parent fbfc4c2 commit cf7c700
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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):
"""
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_course_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(), Mock()

result = IDVPageURLRequested.run_filter(url)

self.assertEquals(url, result)

0 comments on commit cf7c700

Please sign in to comment.