def test_is_process_suspended_tags(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    tags = [{"Key": "TestKey", "Value": "TestValue"}]
    process_names = ["Launch"]
    client.get_paginator.return_value.paginate.return_value = [
        {
            "AutoScalingGroups": [
                {
                    "AutoScalingGroupName": "AutoScalingGroup-A",
                    "SuspendedProcesses": ["Launch"],
                    "Tags": [
                        {
                            "ResourceId": "AutoScalingGroup-A",
                            "Key": "TestKey",
                            "Value": "TestValue",
                        }
                    ],
                }
            ]
        }
    ]
    client.describe_auto_scaling_groups.return_value = {
        "AutoScalingGroups": [
            {
                "AutoScalingGroupName": "AutoScalingGroup-A",
                "SuspendedProcesses": [{"ProcessName": "Launch"}],
            }
        ]
    }
    assert process_is_suspended(tags=tags, process_names=process_names) is True
Beispiel #2
0
def test_is_process_suspended_names_false(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    asg_names = ['AutoScalingGroup-A']
    process_names = ['Launch']
    client.get_paginator.return_value.paginate.return_value = [{
        "AutoScalingGroups": [{
            "AutoScalingGroupName": "AutoScalingGroup-A",
            "SuspendedProcesses": [{"ProcessName": "AZRebalance"}]}]}]
    assert process_is_suspended(
        asg_names=asg_names, process_names=process_names) is False
    assert client.suspend
def test_is_process_suspended_names_true(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    asg_names = ["AutoScalingGroup-A"]
    process_names = ["Launch"]
    client.get_paginator.return_value.paginate.return_value = [
        {
            "AutoScalingGroups": [
                {
                    "AutoScalingGroupName": "AutoScalingGroup-A",
                    "SuspendedProcesses": [{"ProcessName": "Launch"}],
                }
            ]
        }
    ]
    assert (
        process_is_suspended(asg_names=asg_names, process_names=process_names) is True
    )
    assert client.suspend