From 8403c8b50364e7d8cb0bd1c2835db17af65b1dc5 Mon Sep 17 00:00:00 2001 From: Jose Ignacio Palma Date: Thu, 18 Jul 2024 19:52:29 -0400 Subject: [PATCH 1/2] feat: adds CourseAboutPageURLRequested and LMSPageURLRequested filters --- CHANGELOG.rst | 9 ++++++ openedx_filters/__init__.py | 2 +- openedx_filters/course_authoring/__init__.py | 6 ++++ openedx_filters/course_authoring/filters.py | 25 +++++++++++++++ .../course_authoring/tests/__init__.py | 3 ++ .../course_authoring/tests/test_filters.py | 32 +++++++++++++++++++ openedx_filters/learning/filters.py | 20 ++++++++++++ .../learning/tests/test_filters.py | 24 ++++++++++++++ 8 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 openedx_filters/course_authoring/__init__.py create mode 100644 openedx_filters/course_authoring/filters.py create mode 100644 openedx_filters/course_authoring/tests/__init__.py create mode 100644 openedx_filters/course_authoring/tests/test_filters.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 40ec1ed1..c7dde35b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,15 @@ Unreleased ---------- * Configuration for automatic filters docs generation. +[1.11.0] - 2024-09-30 +-------------------- + +Added +~~~~~ + +* CourseAboutPageURLRequested filter added which can be used to modify the URL for the course about organization. +* LMSPageURLRequested filter added which can be used to modify the URL for the LMS page organization. + [1.10.0] - 2024-09-20 -------------------- diff --git a/openedx_filters/__init__.py b/openedx_filters/__init__.py index fd050254..46c47291 100644 --- a/openedx_filters/__init__.py +++ b/openedx_filters/__init__.py @@ -3,4 +3,4 @@ """ from openedx_filters.filters import * -__version__ = "1.10.0" +__version__ = "1.11.0" diff --git a/openedx_filters/course_authoring/__init__.py b/openedx_filters/course_authoring/__init__.py new file mode 100644 index 00000000..bef19c12 --- /dev/null +++ b/openedx_filters/course_authoring/__init__.py @@ -0,0 +1,6 @@ +""" +Package where events related to the ``content_authoring`` subdomain are implemented. + +The ``content_authoring`` subdomain corresponds to {Architecture Subdomain} defined in OEP-41. +https://open-edx-proposals.readthedocs.io/en/latest/architectural-decisions/oep-0041-arch-async-server-event-messaging.html +""" diff --git a/openedx_filters/course_authoring/filters.py b/openedx_filters/course_authoring/filters.py new file mode 100644 index 00000000..fd8c42b2 --- /dev/null +++ b/openedx_filters/course_authoring/filters.py @@ -0,0 +1,25 @@ +""" +Package where filters related to the Course Authoring architectural subdomain are implemented. +""" + +from openedx_filters.tooling import OpenEdxPublicFilter + + +class LMSPageURLRequested(OpenEdxPublicFilter): + """ + Custom class used to get lms page url filters and its custom methods. + """ + + filter_type = "org.openedx.course_authoring.lms.page.url.requested.v1" + + @classmethod + def run_filter(cls, url, org): + """ + Execute a filter with the signature specified. + + Arguments: + url (str): the URL of the page to be modified. + org (str): Course org filter used as context data to get LMS configurations. + """ + data = super().run_pipeline(url=url, org=org) + return data.get("url"), data.get("org") diff --git a/openedx_filters/course_authoring/tests/__init__.py b/openedx_filters/course_authoring/tests/__init__.py new file mode 100644 index 00000000..deb46971 --- /dev/null +++ b/openedx_filters/course_authoring/tests/__init__.py @@ -0,0 +1,3 @@ +""" +Package where unittest for authoring subdomain filters are located. +""" diff --git a/openedx_filters/course_authoring/tests/test_filters.py b/openedx_filters/course_authoring/tests/test_filters.py new file mode 100644 index 00000000..46d17fd5 --- /dev/null +++ b/openedx_filters/course_authoring/tests/test_filters.py @@ -0,0 +1,32 @@ +""" +Tests for authoring subdomain filters. +""" +from unittest.mock import Mock + +from django.test import TestCase + +from openedx_filters.course_authoring.filters import LMSPageURLRequested + + +class TestCourseAuthoringFilters(TestCase): + """ + Test class to verify standard behavior of the filters located in rendering views. + You'll find test suites for: + + - LMSPageURLRequested + """ + + def test_lms_page_url_requested(self): + """ + Test LMSPageURLRequested filter behavior under normal conditions. + + Expected behavior: + - The filter should return lms page url requested. + """ + url = Mock() + org = Mock() + + url_result, org_result = LMSPageURLRequested.run_filter(url, org) + + self.assertEqual(url, url_result) + self.assertEqual(org, org_result) diff --git a/openedx_filters/learning/filters.py b/openedx_filters/learning/filters.py index dc39b8db..011d0149 100644 --- a/openedx_filters/learning/filters.py +++ b/openedx_filters/learning/filters.py @@ -798,3 +798,23 @@ def run_filter(cls, url: str): """ data = super().run_pipeline(url=url) return data.get("url") + + +class CourseAboutPageURLRequested(OpenEdxPublicFilter): + """ + Custom class used to get course about page url filters and its custom methods. + """ + + filter_type = "org.openedx.learning.course_about.page.url.requested.v1" + + @classmethod + def run_filter(cls, url, org): + """ + Execute a filter with the specified signature. + + Arguments: + url (str): the URL of the page to be modified. + org (str): Course org filter used as context data to get LMS configurations. + """ + data = super().run_pipeline(url=url, org=org) + return data.get("url"), data.get("org") diff --git a/openedx_filters/learning/tests/test_filters.py b/openedx_filters/learning/tests/test_filters.py index 203728cf..41896ccb 100644 --- a/openedx_filters/learning/tests/test_filters.py +++ b/openedx_filters/learning/tests/test_filters.py @@ -12,6 +12,7 @@ CertificateRenderStarted, CohortAssignmentRequested, CohortChangeRequested, + CourseAboutPageURLRequested, CourseAboutRenderStarted, CourseEnrollmentAPIRenderStarted, CourseEnrollmentQuerysetRequested, @@ -752,3 +753,26 @@ def test_idv_page_url_requested(self): result = IDVPageURLRequested.run_filter(url) self.assertEqual(url, result) + + +class TestCourseAboutPageURLRequested(TestCase): + """ + Test class to verify standard behavior of the ID verification filters. + You'll find test suites for: + + - CourseAboutPageURLRequested + """ + + def test_lms_page_url_requested(self): + """ + Test CourseAboutPageURLRequested filter behavior under normal conditions. + Expected behavior: + - The filter should return lms page url requested. + """ + url = Mock() + org = Mock() + + url_result, org_result = CourseAboutPageURLRequested.run_filter(url, org) + + self.assertEqual(url, url_result) + self.assertEqual(org, org_result) From 0b8e2a01a7b50f9c4572a29d291ce865c1c9e728 Mon Sep 17 00:00:00 2001 From: Maria Grimaldi Date: Mon, 30 Sep 2024 21:54:04 +0200 Subject: [PATCH 2/2] docs: fix format for changelog file --- CHANGELOG.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c7dde35b..2ecc289d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,16 +16,16 @@ Unreleased * Configuration for automatic filters docs generation. [1.11.0] - 2024-09-30 --------------------- +--------------------- Added ~~~~~ -* CourseAboutPageURLRequested filter added which can be used to modify the URL for the course about organization. -* LMSPageURLRequested filter added which can be used to modify the URL for the LMS page organization. +* CourseAboutPageURLRequested filter added which can be used to modify the URL for the course about page. +* LMSPageURLRequested filter added which can be used to modify the URL for the LMS page. [1.10.0] - 2024-09-20 --------------------- +--------------------- Added ~~~~~