From 9cf6b059ee30e6c2f755c30cc3008dfa59c167bb Mon Sep 17 00:00:00 2001 From: Hamzah Ullah Date: Thu, 10 Sep 2026 13:03:11 -0400 Subject: [PATCH] fix: change SupportContactEnterpriseTagStep to accept/return full context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per pwnage101's review feedback on edx-platform PR #455, matches the updated SupportContactContextRequested filter shape: run_filter now takes a single context dict (reading/writing context['tags']) instead of a bare tags list plus an unused user argument. user was never actually used by this step in the first place — get_current_request() already provides everything needed via crum. ENT-11574 --- CHANGELOG.rst | 4 ++++ enterprise/__init__.py | 2 +- enterprise/filters/support.py | 9 +++++---- tests/filters/test_support.py | 29 ++++++++++++----------------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5f572eb90..2988d34b6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,10 @@ Unreleased ---------- * nothing unreleased +[8.11.0] - 2026-09-10 +---------------------- +* fix: change SupportContactEnterpriseTagStep to accept/return full context (ENT-11574) + [8.10.0] - 2026-09-08 ---------------------- * feat: add SupportContactEnterpriseTagStep pipeline step (ENT-11574) diff --git a/enterprise/__init__.py b/enterprise/__init__.py index b64484524..6c9d70abc 100644 --- a/enterprise/__init__.py +++ b/enterprise/__init__.py @@ -2,4 +2,4 @@ Your project description goes here. """ -__version__ = "8.10.0" +__version__ = "8.11.0" diff --git a/enterprise/filters/support.py b/enterprise/filters/support.py index 646d89a35..ce61cf432 100644 --- a/enterprise/filters/support.py +++ b/enterprise/filters/support.py @@ -20,13 +20,14 @@ class SupportContactEnterpriseTagStep(PipelineStep): ``org.openedx.learning.support.contact.context.requested.v1`` filter. """ - def run_filter(self, tags, user): # pylint: disable=arguments-differ + def run_filter(self, context): # pylint: disable=arguments-differ """ - Append 'enterprise_learner' to tags if the requester is linked to a customer account. + Append 'enterprise_learner' to context['tags'] if the requester is linked to a customer account. """ request = get_current_request() customer = enterprise_customer_for_request(request) + tags = context.get('tags', []) if customer and 'enterprise_learner' not in tags: - tags = [*tags, 'enterprise_learner'] + context = {**context, 'tags': [*tags, 'enterprise_learner']} - return {'tags': tags, 'user': user} + return {'context': context} diff --git a/tests/filters/test_support.py b/tests/filters/test_support.py index ee222c8c5..8041a2131 100644 --- a/tests/filters/test_support.py +++ b/tests/filters/test_support.py @@ -6,7 +6,6 @@ from django.test import RequestFactory, TestCase from enterprise.filters.support import SupportContactEnterpriseTagStep -from test_utils.factories import UserFactory CONTACT_FILTER_TYPE = "org.openedx.learning.support.contact.context.requested.v1" @@ -27,49 +26,45 @@ def _make_request(self): def test_appends_tag_for_linked_customer_request(self, mock_get_current_request, mock_customer_for_request): """ When the request is associated with a linked customer account, 'enterprise_learner' - is appended to the tags list. + is appended to context['tags']. """ mock_customer_for_request.return_value = {'uuid': 'some-uuid', 'name': 'Test Customer'} request = self._make_request() mock_get_current_request.return_value = request - user = UserFactory() - tags = ['some_tag'] + context = {'tags': ['some_tag']} step = self._make_step() - result = step.run_filter(tags=tags, user=user) + result = step.run_filter(context=context) - assert result['tags'] == ['some_tag', 'enterprise_learner'] - assert result['user'] is user + assert result['context']['tags'] == ['some_tag', 'enterprise_learner'] mock_customer_for_request.assert_called_once_with(request) @patch('enterprise.filters.support.enterprise_customer_for_request') @patch('enterprise.filters.support.get_current_request') def test_does_not_duplicate_tag(self, mock_get_current_request, mock_customer_for_request): """ - When 'enterprise_learner' is already in the tags list, it is not duplicated. + When 'enterprise_learner' is already in context['tags'], it is not duplicated. """ mock_customer_for_request.return_value = {'uuid': 'some-uuid', 'name': 'Test Customer'} mock_get_current_request.return_value = self._make_request() - user = UserFactory() - tags = ['enterprise_learner'] + context = {'tags': ['enterprise_learner']} step = self._make_step() - result = step.run_filter(tags=tags, user=user) + result = step.run_filter(context=context) - assert result['tags'].count('enterprise_learner') == 1 + assert result['context']['tags'].count('enterprise_learner') == 1 @patch('enterprise.filters.support.enterprise_customer_for_request') @patch('enterprise.filters.support.get_current_request') def test_does_not_append_tag_for_unlinked_request(self, mock_get_current_request, mock_customer_for_request): """ - When the request is not associated with a linked customer account, tags are unchanged. + When the request is not associated with a linked customer account, context['tags'] is unchanged. """ mock_customer_for_request.return_value = None mock_get_current_request.return_value = self._make_request() - user = UserFactory() - tags = ['some_tag'] + context = {'tags': ['some_tag']} step = self._make_step() - result = step.run_filter(tags=tags, user=user) + result = step.run_filter(context=context) - assert result['tags'] == ['some_tag'] + assert result['context']['tags'] == ['some_tag']