|
1 | 1 | from typing import Dict, List
|
2 | 2 |
|
3 |
| -import pytest # noqa: F401 |
| 3 | +import pytest |
4 | 4 | from botocore.config import Config
|
5 | 5 |
|
6 |
| -from aws_lambda_powertools.utilities.feature_toggles import ConfigurationError |
| 6 | +from aws_lambda_powertools.utilities.feature_toggles import ConfigurationError, schema |
7 | 7 | from aws_lambda_powertools.utilities.feature_toggles.appconfig_fetcher import AppConfigFetcher
|
8 | 8 | from aws_lambda_powertools.utilities.feature_toggles.configuration_store import ConfigurationStore
|
9 | 9 | from aws_lambda_powertools.utilities.feature_toggles.schema import ACTION
|
@@ -442,3 +442,34 @@ def test_app_config_get_parameter_err(mocker, config):
|
442 | 442 |
|
443 | 443 | # THEN raise ConfigurationError error
|
444 | 444 | 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