Commit 53bf4ef3 by Eric Fischer Committed by GitHub

Merge pull request #14856 from edx/efischer/waffle_util_cleanup

Waffle Utils Touchup
parents 252515e4 7d2dbf4b
...@@ -1451,7 +1451,7 @@ class ProgressPageTests(ModuleStoreTestCase): ...@@ -1451,7 +1451,7 @@ class ProgressPageTests(ModuleStoreTestCase):
@ddt.unpack @ddt.unpack
def test_progress_queries(self, enable_waffle, initial, subsequent): def test_progress_queries(self, enable_waffle, initial, subsequent):
self.setup_course() 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): with self.assertNumQueries(initial), check_mongo_calls(1):
self._get_progress_page() self._get_progress_page()
......
...@@ -61,12 +61,13 @@ class WaffleSwitchPlus(WafflePlus): ...@@ -61,12 +61,13 @@ class WaffleSwitchPlus(WafflePlus):
""" """
Overrides the active value for the given switch for the duration of this Overrides the active value for the given switch for the duration of this
contextmanager. 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) previous_active = self.is_enabled(switch_name)
try: try:
self.override_for_request(switch_name, active) self.override_for_request(switch_name, active)
yield with self.override_in_model(switch_name, active):
yield
finally: finally:
self.override_for_request(switch_name, previous_active) self.override_for_request(switch_name, previous_active)
...@@ -85,12 +86,12 @@ class WaffleSwitchPlus(WafflePlus): ...@@ -85,12 +86,12 @@ class WaffleSwitchPlus(WafflePlus):
""" """
Overrides the active value for the given switch for the duration of this Overrides the active value for the given switch for the duration of this
contextmanager. 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)
namespaced_switch_name = self._namespaced_setting_name(switch_name) with waffle_override_switch(namespaced_switch_name, active):
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 yield
@property @property
def _cached_switches(self): def _cached_switches(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment