def test_is_scaling_in_progress_false(aws_client): client = MagicMock() aws_client.return_value = client tags = [{"Key": "Application", "Value": "mychaosapp"}] client.describe_auto_scaling_groups.return_value = { "AutoScalingGroups": [ { "AutoScalingGroupName": "AutoScalingGroup1", "DesiredCapacity": 1, "Instances": [ {"HealthStatus": "Healthy", "LifecycleState": "InService"} ], "Tags": [ { "ResourceId": "AutoScalingGroup1", "Key": "Application", "Value": "mychaosapp", } ], } ] } client.get_paginator.return_value.paginate.return_value = [ { "AutoScalingGroups": [ { "AutoScalingGroupName": "AutoScalingGroup1", "DesiredCapacity": 1, "Instances": [ {"HealthStatus": "Healthy", "LifecycleState": "InService"} ], "Tags": [ { "ResourceId": "AutoScalingGroup1", "Key": "Application", "Value": "mychaosapp", } ], } ] } ] assert is_scaling_in_progress(tags=tags) is False
def test_is_scaling_in_progress_false(aws_client): client = MagicMock() aws_client.return_value = client tags = [{'Key': 'Application', 'Value': 'mychaosapp'}] client.describe_auto_scaling_groups.return_value = \ { "AutoScalingGroups": [ { 'AutoScalingGroupName': 'AutoScalingGroup1', "DesiredCapacity": 1, "Instances": [{ "HealthStatus": "Healthy", "LifecycleState": "InService" }], 'Tags': [{ 'ResourceId': 'AutoScalingGroup1', 'Key': 'Application', 'Value': 'mychaosapp' }] } ] } client.get_paginator.return_value.paginate.return_value = [{ "AutoScalingGroups": [ { 'AutoScalingGroupName': 'AutoScalingGroup1', "DesiredCapacity": 1, "Instances": [{ "HealthStatus": "Healthy", "LifecycleState": "InService" }], 'Tags': [{ 'ResourceId': 'AutoScalingGroup1', 'Key': 'Application', 'Value': 'mychaosapp' }] } ] }] assert is_scaling_in_progress(tags=tags) is False
def test_is_scaling_in_progress(): with pytest.raises(FailedActivity) as x: is_scaling_in_progress([]) assert "Non-empty tags is required" in str(x)