Skip to content

Commit 64c1ec8

Browse files
author
Michael Brewer
committed
test(feature-toggles): Add some missing internal tests
1 parent abaace4 commit 64c1ec8

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

tests/functional/feature_toggles/test_feature_toggles.py

+33-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from typing import Dict, List
22

3-
import pytest # noqa: F401
3+
import pytest
44
from botocore.config import Config
55

6-
from aws_lambda_powertools.utilities.feature_toggles import ConfigurationError
6+
from aws_lambda_powertools.utilities.feature_toggles import ConfigurationError, schema
77
from aws_lambda_powertools.utilities.feature_toggles.appconfig_fetcher import AppConfigFetcher
88
from aws_lambda_powertools.utilities.feature_toggles.configuration_store import ConfigurationStore
99
from aws_lambda_powertools.utilities.feature_toggles.schema import ACTION
@@ -442,3 +442,34 @@ def test_app_config_get_parameter_err(mocker, config):
442442

443443
# THEN raise ConfigurationError error
444444
assert "AWS AppConfig configuration" in str(err.value)
445+
446+
447+
def test_match_by_action_no_matching_action(mocker, config):
448+
# GIVEN an unsupported action
449+
conf_store = init_configuration_store(mocker, {}, config)
450+
# WHEN calling _match_by_action
451+
result = conf_store._match_by_action("Foo", None, "foo")
452+
# THEN default to False
453+
assert result is False
454+
455+
456+
def test_match_by_action_attribute_error(mocker, config):
457+
# GIVEN a startswith action and 2 integer
458+
conf_store = init_configuration_store(mocker, {}, config)
459+
# WHEN calling _match_by_action
460+
result = conf_store._match_by_action(ACTION.STARTSWITH.value, 1, 100)
461+
# THEN swallow the AttributeError and return False
462+
assert result is False
463+
464+
465+
def test_is_rule_matched_no_matches(mocker, config):
466+
# GIVEN an empty list of conditions
467+
rule = {schema.CONDITIONS_KEY: []}
468+
rules_context = {}
469+
conf_store = init_configuration_store(mocker, {}, config)
470+
471+
# WHEN calling _is_rule_matched
472+
result = conf_store._is_rule_matched("feature_name", rule, rules_context)
473+
474+
# THEN return False
475+
assert result is False

0 commit comments

Comments
 (0)