Skip to content

Commit d902018

Browse files
committed
refactor: get_all_enabled_feature_toggles to get_enabled_features
1 parent 38c7bd1 commit d902018

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

aws_lambda_powertools/utilities/feature_toggles/feature_flags.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def evaluate(self, *, feature_name: str, context: Optional[Dict[str, Any]] = Non
166166
rules=cast(List, rules_list),
167167
)
168168

169-
def get_all_enabled_feature_toggles(self, *, context: Optional[Dict[str, Any]] = None) -> List[str]:
169+
def get_enabled_features(self, *, context: Optional[Dict[str, Any]] = None) -> List[str]:
170170
"""Get all enabled feature toggles while also taking into account rule_context
171171
(when a feature has defined rules)
172172

docs/utilities/feature_flags.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ Potential changes to be validated when docs are in a better shape
6666
- [x] ~~Use `base.py` for interfaces for consistency (e.g. Metrics, Tracer, etc.)~~
6767
- [x] ~~AppConfig construct parameter names for consistency (e.g. `configuration_name` -> `name`, `service` -> `application`)~~
6868
- [x] ~~Rename `value_if_missing` param to `default` to match Python consistency (e.g. `os.getenv("VAR", default=False)`)~~
69-
- [x] ~~Review `get_feature` in favour of `evaluate`~~
69+
- [x] ~~Rename `get_feature` to `evaluate`~~
70+
- [x] ~~Rename `get_all_enabled_feature_toggles` to `get_enabled_features`~~
7071
- [ ] Some docstrings and logger refer to AWS AppConfig only (outdated given StoreProvider)
7172
- [ ] Review why we're testing a private method(`is_rule_matched`)
7273
- [ ] Review `get_configuration`, `get_json_configuration`

tests/functional/feature_toggles/test_feature_toggles.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def test_multiple_features_enabled(mocker, config):
360360
},
361361
}
362362
conf_store = init_configuration_store(mocker, mocked_app_config_schema, config)
363-
enabled_list: List[str] = conf_store.get_all_enabled_feature_toggles(context={"tenant_id": "6", "username": "a"})
363+
enabled_list: List[str] = conf_store.get_enabled_features(context={"tenant_id": "6", "username": "a"})
364364
assert enabled_list == expected_value
365365

366366

@@ -409,7 +409,7 @@ def test_multiple_features_only_some_enabled(mocker, config):
409409
},
410410
}
411411
conf_store = init_configuration_store(mocker, mocked_app_config_schema, config)
412-
enabled_list: List[str] = conf_store.get_all_enabled_feature_toggles(context={"tenant_id": "6", "username": "a"})
412+
enabled_list: List[str] = conf_store.get_enabled_features(context={"tenant_id": "6", "username": "a"})
413413
assert enabled_list == expected_value
414414

415415

@@ -430,8 +430,8 @@ def test_get_all_enabled_feature_toggles_handles_error(mocker, config):
430430
schema_fetcher = init_fetcher_side_effect(mocker, config, GetParameterError())
431431
conf_store = FeatureFlags(schema_fetcher)
432432

433-
# WHEN calling get_all_enabled_feature_toggles
434-
toggles = conf_store.get_all_enabled_feature_toggles(context=None)
433+
# WHEN calling get_enabled_features
434+
toggles = conf_store.get_enabled_features(context=None)
435435

436436
# THEN handle the error and return an empty list
437437
assert toggles == []

0 commit comments

Comments
 (0)