Skip to content

Commit

Permalink
feat: add filters before registration and user setttings context
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrrypg committed Dec 5, 2022
1 parent 96da9f8 commit 9133bc3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
26 changes: 26 additions & 0 deletions openedx_filters/learning/filters.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
"""
Package where filters related to the learning architectural subdomain are implemented.
"""

from openedx_filters.exceptions import OpenEdxFilterException
from openedx_filters.tooling import OpenEdxPublicFilter
from openedx_filters.utils import SensitiveDataManagementMixin


class AccountSettingsRenderStarted(OpenEdxPublicFilter):
"""
Custom class used to create Account settings filters.
"""

filter_type = "org.openedx.learning.student.settings.render.started.v1"

class PreventAccountSettingsRender(OpenEdxFilterException):
"""
Custom class used to stop the Account settings rendering process.
"""

@classmethod
def run_filter(cls, context):
"""
Execute a filter with the signature specified.
Arguments:
context (dict): context for the account settings page.
"""
data = super().run_pipeline(context=context)
context = data.get("context")
return context


class StudentRegistrationRequested(OpenEdxPublicFilter, SensitiveDataManagementMixin):
"""
Custom class used to create registration filters and its custom methods.
Expand Down
19 changes: 19 additions & 0 deletions openedx_filters/learning/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.test import TestCase

from openedx_filters.learning.filters import (
AccountSettingsRenderStarted,
CertificateCreationRequested,
CertificateRenderStarted,
CohortAssignmentRequested,
Expand Down Expand Up @@ -274,6 +275,7 @@ class TestRenderingFilters(TestCase):
- CourseAboutRenderStarted
- DashboardRenderStarted
- VerticalBlockChildRenderStarted
- AccountSettingsRenderStarted
"""

def setUp(self):
Expand Down Expand Up @@ -376,6 +378,23 @@ def test_verticalblock_child_render_started(self):

self.assertTupleEqual((block, context,), result)

def test_account_settings_render_started(self):
"""
Test AccountSettingsRenderStarted filter behavior under normal conditions.
Expected behavior:
- The filter should return context.
"""
context = {
'duplicate_provider': None,
'disable_courseware_js': True,
'show_dashboard_tabs': True
}

result = AccountSettingsRenderStarted.run_filter(context=context)

self.assertEqual(result, context)


class TestCohortFilters(TestCase):
"""
Expand Down

0 comments on commit 9133bc3

Please sign in to comment.