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: Implement IDV URL Filters #213

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
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)