diff --git a/lms/djangoapps/courseware/tests/test_views.py b/lms/djangoapps/courseware/tests/test_views.py index 13054bbbab..0c0ed4eefd 100644 --- a/lms/djangoapps/courseware/tests/test_views.py +++ b/lms/djangoapps/courseware/tests/test_views.py @@ -1451,7 +1451,7 @@ class ProgressPageTests(ModuleStoreTestCase): @ddt.unpack def test_progress_queries(self, enable_waffle, initial, subsequent): self.setup_course() - with grades_waffle().override_in_model(ASSUME_ZERO_GRADE_IF_ABSENT, active=enable_waffle): + with grades_waffle().override(ASSUME_ZERO_GRADE_IF_ABSENT, active=enable_waffle): with self.assertNumQueries(initial), check_mongo_calls(1): self._get_progress_page() diff --git a/openedx/core/djangolib/waffle_utils.py b/openedx/core/djangolib/waffle_utils.py index b625624e61..5658b9ae33 100644 --- a/openedx/core/djangolib/waffle_utils.py +++ b/openedx/core/djangolib/waffle_utils.py @@ -61,12 +61,13 @@ class WaffleSwitchPlus(WafflePlus): """ Overrides the active value for the given switch for the duration of this contextmanager. - Note: The value is overridden in the request cache, not in the model. + Note: The value is overridden in the request cache AND in the model. """ previous_active = self.is_enabled(switch_name) try: self.override_for_request(switch_name, active) - yield + with self.override_in_model(switch_name, active): + yield finally: self.override_for_request(switch_name, previous_active) @@ -85,12 +86,12 @@ class WaffleSwitchPlus(WafflePlus): """ Overrides the active value for the given switch for the duration of this contextmanager. - Note: The value is overridden in the request cache AND in the model. + Note: The value is overridden in the model, not the request cache. """ - with self.override(switch_name, active): - namespaced_switch_name = self._namespaced_setting_name(switch_name) - with waffle_override_switch(namespaced_switch_name, active): - yield + namespaced_switch_name = self._namespaced_setting_name(switch_name) + with waffle_override_switch(namespaced_switch_name, active): + log.info(u"%sSwitch '%s' set to %s in model.", self.log_prefix, namespaced_switch_name, active) + yield @property def _cached_switches(self):