Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions lms/djangoapps/support/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,50 @@ def setUp(self):
assert success, 'Could not log in'


class ContactUsViewTests(SupportViewTestCase):
"""
Tests for ContactUsView.
"""

@override_settings(ZENDESK_URL='https://example.zendesk.com')
@patch('lms.djangoapps.support.views.contact_us.SupportContactContextRequested.run_filter')
def test_tags_run_through_filter_for_authenticated_user(self, mock_run_filter):
"""
For an authenticated user, the tags list is passed through the
SupportContactContextRequested filter, and the filter's return value is used
as the final tags list in the rendered context.

The behavior of the filter's pipeline step (edx-enterprise's SupportContactEnterpriseTagStep)
is covered by edx-enterprise's own test suite. This view only needs to verify it wires
the filter's return value through correctly.
"""
mock_run_filter.return_value = (['LMS', 'enterprise_learner'], self.user)

response = self.client.get(reverse('support:contact_us'))

assert response.status_code == 200
mock_run_filter.assert_called_once()
_, call_kwargs = mock_run_filter.call_args
assert call_kwargs['tags'] == ['LMS']
assert call_kwargs['user'] == self.user
assert 'request' not in call_kwargs
assert b'enterprise_learner' in response.content

def test_filter_not_called_for_anonymous_user(self):
"""
Anonymous users never reach the enterprise-tagging branch.
"""
self.client.logout()
with override_settings(ZENDESK_URL='https://example.zendesk.com'):
with patch(
'lms.djangoapps.support.views.contact_us.SupportContactContextRequested.run_filter'
) as mock_run_filter:
response = self.client.get(reverse('support:contact_us'))

assert response.status_code == 200
mock_run_filter.assert_not_called()


class SupportViewManageUserTests(SupportViewTestCase):
"""
Base class for support view tests.
Expand Down
6 changes: 2 additions & 4 deletions lms/djangoapps/support/views/contact_us.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from django.http import Http404
from django.shortcuts import redirect
from django.views.generic import View
from openedx_filters.learning.filters import SupportContactContextRequested

from common.djangoapps.edxmako.shortcuts import marketing_link, render_to_response
from common.djangoapps.student.models import CourseEnrollment
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.features.enterprise_support import api as enterprise_api


class ContactUsView(View):
Expand Down Expand Up @@ -47,9 +47,7 @@ def get(self, request): # pylint: disable=missing-function-docstring
if request.user.is_authenticated:
context['course_id'] = request.session.get('course_id', '')
context['user_enrollments'] = CourseEnrollment.enrollments_for_user_with_overviews_preload(request.user)
enterprise_customer = enterprise_api.enterprise_customer_for_request(request)
if enterprise_customer:
tags.append('enterprise_learner')
tags, _ = SupportContactContextRequested.run_filter(tags=tags, user=request.user)

context['tags'] = tags

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ constraint-dependencies = [
"sphinx-autoapi<3.6.1",
"setuptools<82",
"astroid==4.0.4",
"edx-enterprise==8.9.4",
"edx-enterprise==8.10.0",
"djangorestframework<3.18",
]
[tool.edx_lint]
Expand Down Expand Up @@ -407,7 +407,7 @@ uv_constraints = [
# The team that owns this package will manually bump this package rather than
# having it pulled in automatically. This is to allow them to better control its
# deployment and to do it in a process that works better for them.
"edx-enterprise==8.9.4",
"edx-enterprise==8.10.0",
# Date: 2026-08-31
# DRF 3.18.0 changes many=True validation errors from a list to a dict keyed by
# item index, which breaks the error response shape of several write endpoints.
Expand Down
4 changes: 2 additions & 2 deletions requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ edx-drf-extensions==10.8.0
# openedx-authz
# openedx-core
# openedx-platform
edx-enterprise==8.9.4
edx-enterprise==8.10.0
# via openedx-platform
edx-event-bus-kafka==6.1.0
# via openedx-platform
Expand Down Expand Up @@ -845,7 +845,7 @@ openedx-events==11.2.0
# openedx-core
# openedx-platform
# ora2
openedx-filters==3.9.0
openedx-filters==3.10.0
# via
# edx-enterprise
# lti-consumer-xblock
Expand Down
4 changes: 2 additions & 2 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ edx-drf-extensions==10.8.0
# openedx-authz
# openedx-core
# openedx-platform
edx-enterprise==8.9.4
edx-enterprise==8.10.0
# via openedx-platform
edx-event-bus-kafka==6.1.0
# via openedx-platform
Expand Down Expand Up @@ -947,7 +947,7 @@ openedx-events==11.2.0
# openedx-core
# openedx-platform
# ora2
openedx-filters==3.9.0
openedx-filters==3.10.0
# via
# edx-enterprise
# lti-consumer-xblock
Expand Down
14 changes: 7 additions & 7 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading