diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 0f029d2f..363472a3 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -9,7 +9,12 @@ version: 2 sphinx: configuration: docs/conf.py +# Set the version of python needed to build these docs. +build: + os: "ubuntu-22.04" + tools: + python: "3.8" + python: - version: 3.8 install: - requirements: requirements/doc.txt diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ae135f65..3341d679 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,11 @@ Change Log Unreleased ~~~~~~~~~~ +[8.0.0] +~~~~~~~ + +* **BREAKING CHANGE**: Add transformer argument to openedx dynamic filter. + [7.2.0] ~~~~~~~ diff --git a/event_routing_backends/__init__.py b/event_routing_backends/__init__.py index 90339be4..445132b5 100644 --- a/event_routing_backends/__init__.py +++ b/event_routing_backends/__init__.py @@ -2,4 +2,4 @@ Various backends for receiving edX LMS events.. """ -__version__ = '7.2.0' +__version__ = '8.0.0' diff --git a/event_routing_backends/processors/openedx_filters/decorators.py b/event_routing_backends/processors/openedx_filters/decorators.py index ff64a3dc..adb1b4fe 100644 --- a/event_routing_backends/processors/openedx_filters/decorators.py +++ b/event_routing_backends/processors/openedx_filters/decorators.py @@ -41,6 +41,7 @@ def inner_wrapper(*args, **kwargs): dynamic_filter = ProcessorBaseFilter.generate_dynamic_filter(filter_type=filter_type) return dynamic_filter.run_filter( + transformer=args[0], result=func(*args, **kwargs), ) diff --git a/event_routing_backends/processors/openedx_filters/filters.py b/event_routing_backends/processors/openedx_filters/filters.py index c00028df..7f02aa18 100644 --- a/event_routing_backends/processors/openedx_filters/filters.py +++ b/event_routing_backends/processors/openedx_filters/filters.py @@ -28,11 +28,12 @@ def generate_dynamic_filter(cls, filter_type): return type("DynamicFilter", (cls,), {"filter_type": filter_type}) @classmethod - def run_filter(cls, result): + def run_filter(cls, transformer, result): """ Executes a filter after validating the right class configuration. Arguments: + transformer: XApiTransformer instance. result: Result to be modified or extended. Returns: @@ -45,6 +46,6 @@ def run_filter(cls, result): if not cls.filter_type: raise InvalidFilterType("Parameter filter_type has not been set.") - data = super().run_pipeline(result=result) + data = super().run_pipeline(transformer=transformer, result=result) return data.get("result", result) diff --git a/event_routing_backends/processors/tests/openedx_filters/test_filters.py b/event_routing_backends/processors/tests/openedx_filters/test_filters.py index eec91e4d..6f186ad8 100644 --- a/event_routing_backends/processors/tests/openedx_filters/test_filters.py +++ b/event_routing_backends/processors/tests/openedx_filters/test_filters.py @@ -1,6 +1,6 @@ """Test cases for the filters file.""" from django.test import TestCase -from mock import patch +from mock import Mock, patch from openedx_filters.tooling import OpenEdxPublicFilter from event_routing_backends.processors.openedx_filters.exceptions import InvalidFilterType @@ -17,7 +17,7 @@ def test_invalid_configuration(self): Expected behavior: - InvalidFilterType exception is raised """ - self.assertRaises(InvalidFilterType, ProcessorBaseFilter.run_filter, "dummy_value") + self.assertRaises(InvalidFilterType, ProcessorBaseFilter.run_filter, Mock(), "dummy_value") @patch.object(OpenEdxPublicFilter, "run_pipeline") def test_expected_value(self, run_pipeline_mock): @@ -28,13 +28,14 @@ def test_expected_value(self, run_pipeline_mock): - run_pipeline is called with the right key and value - run_filter returns the value of the result key """ + transformer = Mock() run_pipeline_mock.return_value = { "result": "expected_value" } input_value = "dummy_value" openedx_filter = ProcessorBaseFilter.generate_dynamic_filter(filter_type="test_filter") - result = openedx_filter.run_filter(result=input_value) + result = openedx_filter.run_filter(transformer=transformer, result=input_value) - run_pipeline_mock.assert_called_once_with(result=input_value) + run_pipeline_mock.assert_called_once_with(transformer=transformer, result=input_value) self.assertEqual(run_pipeline_mock()["result"], result) diff --git a/setup.cfg b/setup.cfg index f554d7b8..5fdd2a45 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 7.2.0 +current_version = 8.0.0 commit = False tag = False