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.
18 lines
467 B
Python
18 lines
467 B
Python
from contextlib import contextmanager
|
|
|
|
from mock import patch
|
|
|
|
from edx_toggles.toggles.testutils import override_waffle_flag
|
|
|
|
|
|
@contextmanager
|
|
def override_experiment_waffle_flag(flag, active=True, bucket=1):
|
|
"""
|
|
Override both the base waffle flag and the experiment bucket value.
|
|
"""
|
|
if not active:
|
|
bucket = 0
|
|
with override_waffle_flag(flag, active):
|
|
with patch.object(flag, "get_bucket", return_value=bucket):
|
|
yield
|