Skip to content

Commit

Permalink
fix(feature-flags): rules should evaluate with an AND op (#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
ran-isenberg authored Oct 3, 2021
1 parent 610f569 commit 47ae544
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,9 @@ def _evaluate_rules(
if self._evaluate_conditions(rule_name=rule_name, feature_name=feature_name, rule=rule, context=context):
return bool(rule_match_value)

# no rule matched, return default value of feature
self.logger.debug(
f"no rule matched, returning feature default, default={feat_default}, name={feature_name}"
)
return feat_default
return False
# no rule matched, return default value of feature
self.logger.debug(f"no rule matched, returning feature default, default={feat_default}, name={feature_name}")
return feat_default

def get_configuration(self) -> Dict:
"""Get validated feature flag schema from configured store.
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/feature_flags/test_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def test_flags_conditions_no_rule_match_equal_multiple_conditions(mocker, config
# check rule match for multiple of action types
def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_conditions(mocker, config):
expected_value_first_check = True
expected_value_second_check = False
expected_value_second_check = True
expected_value_third_check = False
expected_value_fourth_case = False
expected_value_fourth_check = False
mocked_app_config_schema = {
"my_feature": {
"default": expected_value_third_check,
Expand Down Expand Up @@ -295,9 +295,9 @@ def test_flags_conditions_rule_match_multiple_actions_multiple_rules_multiple_co
toggle = feature_flags.evaluate(
name="my_fake_feature",
context={"tenant_id": "11114446", "username": "ab"},
default=expected_value_fourth_case,
default=expected_value_fourth_check,
)
assert toggle == expected_value_fourth_case
assert toggle == expected_value_fourth_check


# check a case where the feature exists but the rule doesn't match so we revert to the default value of the feature
Expand Down

0 comments on commit 47ae544

Please sign in to comment.