Example #1
0
def test_stop_task(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    cluster = "ecs-cluster"
    task_id = "16fd2706-8baf-433b-82eb-8c7fada847da"
    reason = "unit test"
    stop_task(cluster=cluster, task_id=task_id, reason=reason)
    client.stop_task.assert_called_with(
        cluster=cluster, task=task_id, reason=reason)
Example #2
0
def test_stop_tasks(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    cluster = "ecs-cluster"
    service = "arn:aws:ecs:us-east-1:012345678910:service/my-http-service"
    reason = "unit test"
    client.list_tasks.side_effect = [
        {'taskArns': [
            "arn:aws:ecs:us-east-1:012345678910:task/16fd2706-8baf-433b-82eb-8c7fada847da"], 'nextToken': 'token0'},
        {'taskArns': [
            "arn:aws:ecs:us-east-1:012345678910:task/84th9568-3tth-55g1-35ki-4o9amby245lk"], 'nextToken': None}
    ]
    stop_task(cluster=cluster, service=service, reason=reason)

    args, kwargs = client.stop_task.call_args
    assert kwargs["task"] in ("16fd2706-8baf-433b-82eb-8c7fada847da",
                              "84th9568-3tth-55g1-35ki-4o9amby245lk")