test: Replace calls to reverse('courseware')
We want to remove this page and URL endpoint so we're removing all the references in the code that might point to this page. It was replaced by the sequences page in the Learning MFE years ago but the old pages were never cleaned up. We are replacing the calls with the URL for the courseware in the learning MFE. See https://github.com/openedx/edx-platform/issues/35803 for more details.
This commit is contained in:
@@ -47,6 +47,7 @@ from openedx.core.djangoapps.content.course_overviews.tests.factories import Cou
|
||||
from openedx.core.djangoapps.programs.tests.mixins import ProgramsApiConfigMixin
|
||||
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
|
||||
from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url
|
||||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, check_mongo_calls # lint-amnesty, pylint: disable=wrong-import-order
|
||||
from xmodule.data import CertificatesDisplayBehaviors # lint-amnesty, pylint: disable=wrong-import-order
|
||||
@@ -907,15 +908,15 @@ class ChangeEnrollmentViewTest(ModuleStoreTestCase):
|
||||
)
|
||||
return response
|
||||
|
||||
@ddt.data(
|
||||
(True, 'courseware'),
|
||||
(False, None),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_enrollment_url(self, waffle_flag_enabled, returned_view):
|
||||
with override_waffle_switch(REDIRECT_TO_COURSEWARE_AFTER_ENROLLMENT, waffle_flag_enabled):
|
||||
def test_enrollment_url_without_redirect(self):
|
||||
with override_waffle_switch(REDIRECT_TO_COURSEWARE_AFTER_ENROLLMENT, False):
|
||||
response = self._enroll_through_view(self.course)
|
||||
data = reverse(returned_view, args=[str(self.course.id)]) if returned_view else ''
|
||||
assert response.content.decode('utf8') == ''
|
||||
|
||||
def test_enrollment_with_redirect(self):
|
||||
with override_waffle_switch(REDIRECT_TO_COURSEWARE_AFTER_ENROLLMENT, True):
|
||||
response = self._enroll_through_view(self.course)
|
||||
data = make_learning_mfe_courseware_url(self.course.id)
|
||||
assert response.content.decode('utf8') == data
|
||||
|
||||
def test_enroll_as_default(self):
|
||||
|
||||
@@ -62,6 +62,7 @@ from openedx.core.djangoapps.user_authn.toggles import (
|
||||
)
|
||||
from openedx.core.djangolib.markup import HTML, Text
|
||||
from openedx.core.lib.api.authentication import BearerAuthenticationAllowInactiveUser
|
||||
from openedx.features.course_experience.url_helpers import make_learning_mfe_courseware_url
|
||||
from openedx.features.discounts.applicability import FIRST_PURCHASE_DISCOUNT_OVERRIDE_FLAG
|
||||
from openedx.features.enterprise_support.utils import is_enterprise_learner
|
||||
from common.djangoapps.student.email_helpers import generate_activation_email_context
|
||||
@@ -408,7 +409,7 @@ def change_enrollment(request, check_access=True):
|
||||
return HttpResponse(redirect_url)
|
||||
|
||||
if CourseEntitlement.check_for_existing_entitlement_and_enroll(user=user, course_run_key=course_id):
|
||||
return HttpResponse(reverse('courseware', args=[str(course_id)]))
|
||||
return HttpResponse(make_learning_mfe_courseware_url(course_id))
|
||||
|
||||
# Check that auto enrollment is allowed for this course
|
||||
# (= the course is NOT behind a paywall)
|
||||
@@ -438,7 +439,7 @@ def change_enrollment(request, check_access=True):
|
||||
)
|
||||
|
||||
if should_redirect_to_courseware_after_enrollment():
|
||||
return HttpResponse(reverse('courseware', args=[str(course_id)]))
|
||||
return HttpResponse(make_learning_mfe_courseware_url(course_id))
|
||||
else:
|
||||
return HttpResponse()
|
||||
elif action == "unenroll":
|
||||
|
||||
Reference in New Issue
Block a user