def test_delete_filtered_service(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    cluster = "ecs-cluster"

    svc1 = "arn:aws:ecs:us-east-1:012345678910:service/my-http-service"
    svc2 = "arn:aws:ecs:us-east-1:012345678910:service/my-db-service"

    client.list_services.side_effect = [{
        'serviceArns': [svc1],
        'nextToken': 'token0'
    }, {
        'serviceArns': [svc2],
        'nextToken': None
    }]

    delete_service(cluster=cluster, service_pattern="my-db")
    client.update_service.assert_called_with(cluster=cluster,
                                             service="my-db-service",
                                             desiredCount=0,
                                             deploymentConfiguration={
                                                 'maximumPercent': 100,
                                                 'minimumHealthyPercent': 0
                                             })

    client.delete_service.assert_called_with(cluster=cluster,
                                             service="my-db-service")
Exemple #2
0
def test_delete_service(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    cluster = "ecs-cluster"
    svc1 = "my-http-service"

    delete_service(cluster=cluster, service=svc1)
    client.update_service.assert_called_with(
        cluster=cluster, service=svc1, desiredCount=0,
        deploymentConfiguration={
            'maximumPercent': 100,
            'minimumHealthyPercent': 0
        })
    client.delete_service.assert_called_with(cluster=cluster, service=svc1)