Skip to content

Commit fbe223e

Browse files
committed
fixup! feat: remove ENABLE_MKTG_SITE from enrollment, courseware, and mobile API
1 parent 5938f73 commit fbe223e

4 files changed

Lines changed: 45 additions & 12 deletions

File tree

lms/djangoapps/course_wiki/tests/tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from django.urls import reverse
99

1010
from lms.djangoapps.courseware.tests.tests import LoginEnrollmentTestCase
11+
from openedx.features.course_experience import course_home_url
1112
from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url
1213
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseTestConsentRequired
1314
from xmodule.modulestore.tests.django_utils import (
@@ -135,7 +136,7 @@ def test_course_navigator(self):
135136
def test_wiki_not_accessible_when_not_enrolled(self):
136137
"""
137138
Test that going from a course page to a wiki page when not enrolled
138-
redirects a user to the course about page
139+
redirects a user to the course home page
139140
"""
140141

141142
self.login(self.instructor, self.password)
@@ -151,10 +152,10 @@ def test_wiki_not_accessible_when_not_enrolled(self):
151152
resp = self.client.get(course_wiki_page, follow=False, HTTP_REFERER=referer)
152153
assert resp.status_code == 302
153154

154-
# and end up at the course about page
155+
# and end up at the course home page
155156
resp = self.client.get(course_wiki_page, follow=True, HTTP_REFERER=referer)
156157
target_url, __ = resp.redirect_chain[-1]
157-
assert target_url.endswith(reverse('about_course', args=[str(self.toy.id)]))
158+
assert target_url == course_home_url(self.toy.id)
158159

159160
@patch.dict("django.conf.settings.FEATURES", {'ALLOW_WIKI_ROOT_ACCESS': True})
160161
def test_redirect_when_not_logged_in(self):

lms/djangoapps/courseware/tests/test_about.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343

4444
@ddt.ddt
45+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': False})
4546
class AboutTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase, EventTrackingTestCase, MilestonesTestCaseMixin):
4647
"""
4748
Tests about xblock.
@@ -113,6 +114,7 @@ def test_visible_about_page_settings(self):
113114
resp = self.client.get(url)
114115
self.assertRedirects(resp, reverse('dashboard'), fetch_redirect_response=False)
115116

117+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': True})
116118
def test_logged_in_marketing(self):
117119
self.setup_user()
118120
url = reverse('about_course', args=[str(self.course.id)])
@@ -208,6 +210,7 @@ def test_about_page_public_view(self, course_visibility):
208210
self.assertContains(resp, "Enroll Now")
209211

210212

213+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': False})
211214
class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
212215
"""
213216
Tests for the course about page
@@ -251,6 +254,7 @@ def test_anonymous_user_xml(self):
251254
self.assertContains(resp, self.xml_data)
252255

253256

257+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': False})
254258
class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
255259
"""
256260
This test case will check the About page when a course has a capped enrollment
@@ -293,6 +297,7 @@ def test_enrollment_cap(self):
293297
self.assertNotContains(resp, REG_STR)
294298

295299

300+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': False})
296301
class AboutWithInvitationOnly(SharedModuleStoreTestCase):
297302
"""
298303
This test case will check the About page when a course is invitation only.
@@ -332,6 +337,7 @@ def test_invitation_only_but_allowed(self):
332337
self.assertContains(resp, REG_STR)
333338

334339

340+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': False})
335341
class AboutWithClosedEnrollment(ModuleStoreTestCase):
336342
"""
337343
This test case will check the About page for a course that has enrollment start/end
@@ -368,6 +374,7 @@ def test_course_price_is_not_visible_in_sidebar(self):
368374

369375

370376
@ddt.ddt
377+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': False})
371378
class AboutSidebarHTMLTestCase(SharedModuleStoreTestCase):
372379
"""
373380
This test case will check the About page for the content in the HTML sidebar.

lms/djangoapps/courseware/tests/test_filters.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
22
Test that various filters are fired for courseware views.
33
"""
4+
from unittest.mock import patch
5+
6+
from django.conf import settings
47
from django.http import HttpResponse
58
from django.test import override_settings
69
from django.urls import reverse
@@ -104,6 +107,7 @@ def run_filter(self, context, template_name): # pylint: disable=arguments-diffe
104107

105108

106109
@skip_unless_lms
110+
@patch.dict(settings.FEATURES, {'ENABLE_COURSE_HOME_REDIRECT': False})
107111
class CourseAboutFiltersTest(ModuleStoreTestCase):
108112
"""
109113
Tests for the Open edX Filters associated with the course about rendering process.

lms/djangoapps/courseware/tests/test_view_authentication.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from lms.djangoapps.courseware.access import has_access
2424
from lms.djangoapps.courseware.tests.helpers import CourseAccessTestMixin, LoginEnrollmentTestCase
2525
from lms.djangoapps.instructor.toggles import LEGACY_INSTRUCTOR_DASHBOARD
26+
from openedx.features.course_experience import course_home_url
2627
from openedx.features.enterprise_support.tests.mixins.enterprise import EnterpriseTestConsentRequired
2728
from xmodule.modulestore.django import modulestore
2829
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
@@ -58,10 +59,13 @@ def _check_non_staff_light(self, course):
5859
5960
`course` is an instance of CourseBlock.
6061
"""
61-
urls = [reverse('about_course', kwargs={'course_id': str(course.id)}),
62-
reverse('courses')]
63-
for url in urls:
64-
self.assert_request_status_code(200, url)
62+
about_url = reverse('about_course', kwargs={'course_id': str(course.id)})
63+
response = self.client.get(about_url)
64+
assert response.status_code == 302
65+
assert response['Location'] == course_home_url(course.id)
66+
67+
# courses view redirects to / when no marketing URL is configured
68+
self.assert_request_status_code(302, reverse('courses'))
6569

6670
def _check_non_staff_dark(self, course):
6771
"""
@@ -94,9 +98,14 @@ def _check_staff(self, course):
9498
for index in range(len(course.textbooks))
9599
])
96100
for url in urls:
97-
# Instructor dashboard returns 302 (MFE redirect) by default
98101
if 'instructor' in url:
102+
# Instructor dashboard returns 302 (MFE redirect) by default
99103
self.assert_request_status_code(302, url)
104+
elif 'about' in url:
105+
# about_course redirects enrolled users to course home MFE
106+
response = self.client.get(url)
107+
assert response.status_code == 302
108+
assert response['Location'] == course_home_url(course.id)
100109
else:
101110
self.assert_request_status_code(200, url)
102111

@@ -127,8 +136,14 @@ def _check_staff_legacy(self, course):
127136
for index in range(len(course.textbooks))
128137
])
129138
for url in urls:
130-
# With legacy flag enabled, all URLs return 200 (instructor dashboard skips MFE redirect)
131-
self.assert_request_status_code(200, url)
139+
if 'about' in url:
140+
# about_course redirects enrolled users to course home MFE
141+
response = self.client.get(url)
142+
assert response.status_code == 302
143+
assert response['Location'] == course_home_url(course.id)
144+
else:
145+
# With legacy flag enabled, all other URLs return 200
146+
self.assert_request_status_code(200, url)
132147

133148
# The student progress tab behavior is affected by legacy flag in normal scenarios
134149
url = reverse(
@@ -153,8 +168,14 @@ def _check_staff_legacy_dark_launch(self, course):
153168
for index in range(len(course.textbooks))
154169
])
155170
for url in urls:
156-
# With legacy flag enabled, all URLs return 200 (instructor dashboard skips MFE redirect)
157-
self.assert_request_status_code(200, url)
171+
if 'about' in url:
172+
# about_course redirects enrolled users to course home MFE
173+
response = self.client.get(url)
174+
assert response.status_code == 302
175+
assert response['Location'] == course_home_url(course.id)
176+
else:
177+
# With legacy flag enabled, all other URLs return 200
178+
self.assert_request_status_code(200, url)
158179

159180
# In dark launch scenarios, student progress URL still returns 302 even with legacy flag
160181
# because course access restrictions take precedence

0 commit comments

Comments
 (0)