def test_disable(self): strategies = {'Foo': mock.Mock(return_value=lambda z: z)} feature_def = { 'enabled': False, 'strategies': [{'name': 'Foo', 'parameters': {'x': 0}}], } toggle = features.Feature(strategies, feature_def) assert not toggle({'z': True}) assert not toggle({'z': False}) assert toggle.choices == {True: 0, False: 2}
def test_empty_strategy_list(self): strategies = {'Foo': mock.Mock(return_value=lambda z: z)} feature_def = { 'enabled': True, 'strategies': [], } toggle = features.Feature(strategies, feature_def) assert isinstance(toggle, features.Feature) assert not toggle({'z': True}) assert not toggle({'z': False}) assert toggle.choices == {True: 0, False: 2}