edx_toggles.toggles package



edx_toggles.toggles.testutils module

Toggle test utilities.

class edx_toggles.toggles.testutils.override_waffle_flag(flag, active)

Bases: override_flag

override_waffle_flag is a contextmanager for easier testing of flags.

It accepts two parameters, the flag itself and its intended state. Example usage:

with override_waffle_flag(SOME_COURSE_FLAG, active=True):

If the flag already exists, its value will be changed inside the context block, then restored to the original value. If the flag does not exist before entering the context, it is created, then removed at the end of the block.

It can also act as a decorator:

@override_waffle_flag(SOME_COURSE_FLAG, active=True)
def test_happy_mode_enabled():
class edx_toggles.toggles.testutils.override_waffle_switch(switch, active)

Bases: override_switch

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 implementation for overriding switches and flags differ. override_waffle_switch makes an explicit call to WaffleSwitch.is_enabled, which fills the cache, while override_waffle_flag only looks at the cached values. It is unclear whether this difference is important, or just due to being developed at different times by different people.

Module contents

Expose public feature toggle API.