Skip to content

Commit

Permalink
feat: adds CourseAboutPageURLRequested and LMSPageURLRequested filters (
Browse files Browse the repository at this point in the history
  • Loading branch information
jignaciopm committed Sep 30, 2024
1 parent 7c00bcc commit aab1217
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,17 @@ 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 page.
* LMSPageURLRequested filter added which can be used to modify the URL for the LMS page.

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

Added
~~~~~
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.10.0"
__version__ = "1.11.0"
6 changes: 6 additions & 0 deletions openedx_filters/course_authoring/__init__.py
Original file line number Diff line number Diff line change
@@ -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
"""
25 changes: 25 additions & 0 deletions openedx_filters/course_authoring/filters.py
Original file line number Diff line number Diff line change
@@ -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")
3 changes: 3 additions & 0 deletions openedx_filters/course_authoring/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Package where unittest for authoring subdomain filters are located.
"""
32 changes: 32 additions & 0 deletions openedx_filters/course_authoring/tests/test_filters.py
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 20 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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 @@ -12,6 +12,7 @@
CertificateRenderStarted,
CohortAssignmentRequested,
CohortChangeRequested,
CourseAboutPageURLRequested,
CourseAboutRenderStarted,
CourseEnrollmentAPIRenderStarted,
CourseEnrollmentQuerysetRequested,
Expand Down Expand Up @@ -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)

0 comments on commit aab1217

Please sign in to comment.