Reenable Learning Sequence MFE redirect tests
TNL-7157 These tests may were the cause of intermittent test failures a couple weeks ago. Here they are reenabled after changing the way ExperimentWaffleFlag is overridden.
This commit is contained in:
@@ -3256,7 +3256,7 @@ class TestShowCoursewareMFE(TestCase):
|
||||
)
|
||||
for user, course_key, is_course_staff, preview_active, redirect_active in combos:
|
||||
with override_waffle_flag(COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW, preview_active):
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, redirect_active):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=redirect_active):
|
||||
assert show_courseware_mfe_link(user, is_course_staff, course_key) is False
|
||||
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_COURSEWARE_MICROFRONTEND': True})
|
||||
@@ -3276,14 +3276,14 @@ class TestShowCoursewareMFE(TestCase):
|
||||
)
|
||||
for user, is_course_staff, preview_active, redirect_active in old_mongo_combos:
|
||||
with override_waffle_flag(COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW, preview_active):
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, redirect_active):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=redirect_active):
|
||||
assert show_courseware_mfe_link(user, is_course_staff, old_course_key) is False
|
||||
|
||||
# We've checked all old-style course keys now, so we can test only the
|
||||
# new ones going forward. Now we check combinations of waffle flags and
|
||||
# user permissions...
|
||||
with override_waffle_flag(COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW, True):
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, True):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=True):
|
||||
# (preview=on, redirect=on)
|
||||
# Global and Course Staff can see the link.
|
||||
self.assertTrue(show_courseware_mfe_link(global_staff_user, True, new_course_key))
|
||||
@@ -3292,7 +3292,7 @@ class TestShowCoursewareMFE(TestCase):
|
||||
|
||||
# Regular users don't see the link.
|
||||
self.assertFalse(show_courseware_mfe_link(regular_user, False, new_course_key))
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, False):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=False):
|
||||
# (preview=on, redirect=off)
|
||||
# Global and Course Staff can see the link.
|
||||
self.assertTrue(show_courseware_mfe_link(global_staff_user, True, new_course_key))
|
||||
@@ -3303,7 +3303,7 @@ class TestShowCoursewareMFE(TestCase):
|
||||
self.assertFalse(show_courseware_mfe_link(regular_user, False, new_course_key))
|
||||
|
||||
with override_waffle_flag(COURSEWARE_MICROFRONTEND_COURSE_TEAM_PREVIEW, False):
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, True):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=True):
|
||||
# (preview=off, redirect=on)
|
||||
# Global staff see the link anyway
|
||||
self.assertTrue(show_courseware_mfe_link(global_staff_user, True, new_course_key))
|
||||
@@ -3315,7 +3315,7 @@ class TestShowCoursewareMFE(TestCase):
|
||||
|
||||
# Regular users don't see the link.
|
||||
self.assertFalse(show_courseware_mfe_link(regular_user, False, new_course_key))
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, False):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=False):
|
||||
# (preview=off, redirect=off)
|
||||
# Global staff see the link anyway
|
||||
self.assertTrue(show_courseware_mfe_link(global_staff_user, True, new_course_key))
|
||||
@@ -3348,8 +3348,7 @@ class TestShowCoursewareMFE(TestCase):
|
||||
'/block-v1:OpenEdX+MFE+2020+type@vertical+block@Getting_To_Know_You'
|
||||
)
|
||||
|
||||
# TODO: TNL-7157 Re-enable these tests before Courseware MFE Canary
|
||||
@unittest.skip
|
||||
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENABLE_COURSEWARE_MICROFRONTEND': True})
|
||||
@ddt.ddt
|
||||
class MFERedirectTests(BaseViewsTestCase):
|
||||
@@ -3375,7 +3374,7 @@ class MFERedirectTests(BaseViewsTestCase):
|
||||
# learners will be redirected when the waffle flag is set
|
||||
lms_url, mfe_url = self._get_urls()
|
||||
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, True):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=True):
|
||||
assert self.client.get(lms_url).url == mfe_url
|
||||
|
||||
def test_staff_no_redirect(self):
|
||||
@@ -3387,14 +3386,14 @@ class MFERedirectTests(BaseViewsTestCase):
|
||||
self.client.login(username=course_staff.username, password='test')
|
||||
|
||||
assert self.client.get(lms_url).status_code == 200
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, True):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=True):
|
||||
assert self.client.get(lms_url).status_code == 200
|
||||
|
||||
# global staff will never be redirected
|
||||
self._create_global_staff_user()
|
||||
assert self.client.get(lms_url).status_code == 200
|
||||
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, True):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=True):
|
||||
assert self.client.get(lms_url).status_code == 200
|
||||
|
||||
def test_exam_no_redirect(self):
|
||||
@@ -3404,5 +3403,5 @@ class MFERedirectTests(BaseViewsTestCase):
|
||||
|
||||
lms_url, mfe_url = self._get_urls()
|
||||
|
||||
with override_waffle_flag(REDIRECT_TO_COURSEWARE_MICROFRONTEND, True):
|
||||
with REDIRECT_TO_COURSEWARE_MICROFRONTEND.override(active=True):
|
||||
assert self.client.get(lms_url).status_code == 200
|
||||
|
||||
@@ -178,4 +178,8 @@ class ExperimentWaffleFlag(CourseWaffleFlag):
|
||||
if not active:
|
||||
bucket = 0
|
||||
with patch.object(self, 'get_bucket', return_value=bucket):
|
||||
yield
|
||||
# TODO We can move this import to the top of the file once this code is
|
||||
# not all contained within the __init__ module.
|
||||
from openedx.core.djangoapps.waffle_utils.testutils import override_waffle_flag
|
||||
with override_waffle_flag(self, active):
|
||||
yield
|
||||
|
||||
Reference in New Issue
Block a user