Debian Codegraph @

ansible_collections/amazon/aws/tests/unit/plugins/modules/test_autoscaling_instance_refresh.py

raw
1 # (c) 2024 Red Hat Inc.
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3
4 import pytest
5
6 from ansible_collections.amazon.aws.plugins.modules.autoscaling_instance_refresh import validate_healthy_percentage
7
8
9 @pytest.mark.parametrize(
10 "min_healthy, max_healthy, expected_error",
11 [
12 (90, None, None),
13 (-1, None, "The value range for the min_healthy_percentage is 0 to 100."),
14 (101, None, "The value range for the min_healthy_percentage is 0 to 100."),
15 (None, 90, "The value range for the max_healthy_percentage is 100 to 200."),
16 (None, 201, "The value range for the max_healthy_percentage is 100 to 200."),
17 (None, 100, "You must also specify min_healthy_percentage when max_healthy_percentage is specified."),
18 (10, 100, None),
19 (
20 10,
21 150,
22 "The difference between the max_healthy_percentage and min_healthy_percentage cannot be greater than 100.",
23 ),
24 ],
25 )
26 def test_validate_healthy_percentage(min_healthy, max_healthy, expected_error):
27 preferences = dict(min_healthy_percentage=min_healthy, max_healthy_percentage=max_healthy)
28 assert expected_error == validate_healthy_percentage(preferences)