Skip to content

Commit

Permalink
refactor: get_all_enabled_feature_toggles to get_enabled_features
Browse files Browse the repository at this point in the history
  • Loading branch information
heitorlessa committed Jul 30, 2021
1 parent 38c7bd1 commit d902018
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def evaluate(self, *, feature_name: str, context: Optional[Dict[str, Any]] = Non
rules=cast(List, rules_list),
)

def get_all_enabled_feature_toggles(self, *, context: Optional[Dict[str, Any]] = None) -> List[str]:
def get_enabled_features(self, *, context: Optional[Dict[str, Any]] = None) -> List[str]:
"""Get all enabled feature toggles while also taking into account rule_context
(when a feature has defined rules)
Expand Down
3 changes: 2 additions & 1 deletion docs/utilities/feature_flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ Potential changes to be validated when docs are in a better shape
- [x] ~~Use `base.py` for interfaces for consistency (e.g. Metrics, Tracer, etc.)~~
- [x] ~~AppConfig construct parameter names for consistency (e.g. `configuration_name` -> `name`, `service` -> `application`)~~
- [x] ~~Rename `value_if_missing` param to `default` to match Python consistency (e.g. `os.getenv("VAR", default=False)`)~~
- [x] ~~Review `get_feature` in favour of `evaluate`~~
- [x] ~~Rename `get_feature` to `evaluate`~~
- [x] ~~Rename `get_all_enabled_feature_toggles` to `get_enabled_features`~~
- [ ] Some docstrings and logger refer to AWS AppConfig only (outdated given StoreProvider)
- [ ] Review why we're testing a private method(`is_rule_matched`)
- [ ] Review `get_configuration`, `get_json_configuration`
Expand Down
8 changes: 4 additions & 4 deletions tests/functional/feature_toggles/test_feature_toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def test_multiple_features_enabled(mocker, config):
},
}
conf_store = init_configuration_store(mocker, mocked_app_config_schema, config)
enabled_list: List[str] = conf_store.get_all_enabled_feature_toggles(context={"tenant_id": "6", "username": "a"})
enabled_list: List[str] = conf_store.get_enabled_features(context={"tenant_id": "6", "username": "a"})
assert enabled_list == expected_value


Expand Down Expand Up @@ -409,7 +409,7 @@ def test_multiple_features_only_some_enabled(mocker, config):
},
}
conf_store = init_configuration_store(mocker, mocked_app_config_schema, config)
enabled_list: List[str] = conf_store.get_all_enabled_feature_toggles(context={"tenant_id": "6", "username": "a"})
enabled_list: List[str] = conf_store.get_enabled_features(context={"tenant_id": "6", "username": "a"})
assert enabled_list == expected_value


Expand All @@ -430,8 +430,8 @@ def test_get_all_enabled_feature_toggles_handles_error(mocker, config):
schema_fetcher = init_fetcher_side_effect(mocker, config, GetParameterError())
conf_store = FeatureFlags(schema_fetcher)

# WHEN calling get_all_enabled_feature_toggles
toggles = conf_store.get_all_enabled_feature_toggles(context=None)
# WHEN calling get_enabled_features
toggles = conf_store.get_enabled_features(context=None)

# THEN handle the error and return an empty list
assert toggles == []
Expand Down

0 comments on commit d902018

Please sign in to comment.