From cf7c700b2e36cd85a99ca5bd5744fb009b264b3d Mon Sep 17 00:00:00 2001 From: ilee2u Date: Tue, 10 Sep 2024 15:41:04 -0400 Subject: [PATCH 1/4] feat: Implement IDV URL Filters --- openedx_filters/learning/filters.py | 19 +++++++++++++++ .../learning/tests/test_filters.py | 24 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/openedx_filters/learning/filters.py b/openedx_filters/learning/filters.py index f95e4f82..43a4d60f 100644 --- a/openedx_filters/learning/filters.py +++ b/openedx_filters/learning/filters.py @@ -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") diff --git a/openedx_filters/learning/tests/test_filters.py b/openedx_filters/learning/tests/test_filters.py index 9021906b..10dbd723 100644 --- a/openedx_filters/learning/tests/test_filters.py +++ b/openedx_filters/learning/tests/test_filters.py @@ -20,6 +20,7 @@ CourseRunAPIRenderStarted, CourseUnenrollmentStarted, DashboardRenderStarted, + IDVPageURLRequested, InstructorDashboardRenderStarted, ORASubmissionViewRenderStarted, RenderXBlockStarted, @@ -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) From 5329479c90d09b46be6628569d955bb21a187681 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Tue, 10 Sep 2024 15:47:30 -0400 Subject: [PATCH 2/4] chore: lint --- openedx_filters/learning/tests/test_filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx_filters/learning/tests/test_filters.py b/openedx_filters/learning/tests/test_filters.py index 10dbd723..063a8a30 100644 --- a/openedx_filters/learning/tests/test_filters.py +++ b/openedx_filters/learning/tests/test_filters.py @@ -751,4 +751,4 @@ def test_course_idv_page_url_requested(self): result = IDVPageURLRequested.run_filter(url) - self.assertEquals(url, result) + self.assertEqual(url, result) From 86eb3288bcfd97a4dbb4d7bbbbf33606e90674e1 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Tue, 10 Sep 2024 16:44:46 -0400 Subject: [PATCH 3/4] chore: quality --- openedx_filters/learning/filters.py | 2 +- openedx_filters/learning/tests/test_filters.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openedx_filters/learning/filters.py b/openedx_filters/learning/filters.py index 43a4d60f..dc39b8db 100644 --- a/openedx_filters/learning/filters.py +++ b/openedx_filters/learning/filters.py @@ -789,7 +789,7 @@ class IDVPageURLRequested(OpenEdxPublicFilter): filter_type = "org.openedx.learning.idv.page.url.requested.v1" @classmethod - def run_filter(cls, url): + def run_filter(cls, url: str): """ Execute a filter with the specified signature. diff --git a/openedx_filters/learning/tests/test_filters.py b/openedx_filters/learning/tests/test_filters.py index 063a8a30..203728cf 100644 --- a/openedx_filters/learning/tests/test_filters.py +++ b/openedx_filters/learning/tests/test_filters.py @@ -739,7 +739,7 @@ class TestIDVFilters(TestCase): - IDVPageURLRequested """ - def test_course_idv_page_url_requested(self): + def test_idv_page_url_requested(self): """ Test IDVPageURLRequested filter behavior under normal conditions. @@ -747,7 +747,7 @@ def test_course_idv_page_url_requested(self): - The filter must have the signature specified. - The filter should return the url. """ - url = Mock(), Mock() + url = Mock() result = IDVPageURLRequested.run_filter(url) From 5fd28c05e87bec3b3a2da44957081b45068d39a9 Mon Sep 17 00:00:00 2001 From: ilee2u Date: Fri, 20 Sep 2024 09:41:40 -0400 Subject: [PATCH 4/4] chore: changelog + version update --- CHANGELOG.rst | 8 ++++++++ openedx_filters/__init__.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8541c005..40ec1ed1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -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 -------------------- diff --git a/openedx_filters/__init__.py b/openedx_filters/__init__.py index 835c5d54..fd050254 100644 --- a/openedx_filters/__init__.py +++ b/openedx_filters/__init__.py @@ -3,4 +3,4 @@ """ from openedx_filters.filters import * -__version__ = "1.9.0" +__version__ = "1.10.0"