Deprecate ExperimentWaffleFlag.override method

This is part of a removal of the many override methods of toggle
flag/namespace classes. This allows us to remove imports of test modules
from production code.
This commit is contained in:
Régis Behmo
2020-10-23 11:19:41 +02:00
parent 64a162f69c
commit 16ce16e85e
12 changed files with 117 additions and 99 deletions

View File

@@ -1,7 +1,6 @@
"""Tests for Show Answer overrides for self-paced courses."""
import ddt
from django.test import RequestFactory
from django.test.utils import override_settings
@@ -9,6 +8,7 @@ from common.lib.xmodule.xmodule.capa_base import SHOWANSWER
from lms.djangoapps.ccx.tests.test_overrides import inject_field_overrides
from lms.djangoapps.courseware.model_data import FieldDataCache
from lms.djangoapps.courseware.module_render import get_module
from lms.djangoapps.experiments.testutils import override_experiment_waffle_flag
from openedx.features.course_experience import RELATIVE_DATES_FLAG
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
@@ -36,7 +36,7 @@ class ShowAnswerFieldOverrideTest(ModuleStoreTestCase):
@ddt.data(True, False)
def test_override_enabled_for(self, active):
with RELATIVE_DATES_FLAG.override(active=active):
with override_experiment_waffle_flag(RELATIVE_DATES_FLAG, active=active):
# Instructor paced course will just have the default value
ip_course = self.setup_course()
course_module = self.get_course_module(ip_course)
@@ -63,7 +63,7 @@ class ShowAnswerFieldOverrideTest(ModuleStoreTestCase):
(SHOWANSWER.ALWAYS, SHOWANSWER.ALWAYS),
)
@ddt.unpack
@RELATIVE_DATES_FLAG.override(active=True)
@override_experiment_waffle_flag(RELATIVE_DATES_FLAG, active=True)
def test_get(self, initial_value, expected_final_value):
course = self.setup_course(self_paced=True, showanswer=initial_value)
course_module = self.get_course_module(course)