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 e7647e2 commit 7a594a9
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openedx_filters/authoring/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Package where filters related to the authoring subdomain are implemented.
The authoring subdomain corresponds to {Architecture Subdomain} defined in
the OEP-41.
"""
26 changes: 26 additions & 0 deletions openedx_filters/authoring/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Package where filters related to the authoring architectural subdomain are implemented.
"""

from openedx_filters.exceptions import OpenEdxFilterException
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.authoring.lms.page.url.requested.v1"

@classmethod
def run_filter(cls, target_url, org):
"""
Execute a filter with the signature specified.
Arguments:
target_url (str): target url to use.
org (str): Course org filter, this value will be used to filter out the correct lms url configuration.
"""
data = super().run_pipeline(target_url=target_url, org=org)
return data.get("target_url"), data.get("org")
3 changes: 3 additions & 0 deletions openedx_filters/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/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 ddt import data, ddt, unpack
from django.test import TestCase

from openedx_filters.authoring.filters import LMSPageURLRequested


@ddt
class TestAuthoringFilters(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.
"""
target_url = Mock()
org = Mock()

result = LMSPageURLRequested.run_filter(target_url, org)

self.assertEqual((target_url, 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, target_url, org):
"""
Execute a filter with the specified signature.
Arguments:
target_url (str): target url to use.
org (str): Course org filter, this value will be used to filter out the correct lms url configuration.
"""
data = super().run_pipeline(target_url=target_url, org=org)
return data.get("target_url"), data.get("org")
23 changes: 23 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,25 @@ 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.
"""
target_url = Mock()
org = Mock()

result = CourseAboutPageURLRequested.run_filter(target_url, org)

self.assertEqual((target_url, org), result)

0 comments on commit 7a594a9

Please sign in to comment.