From 017cbb52ca7230de20ab004387ad1bcaaed163e4 Mon Sep 17 00:00:00 2001 From: Jamie Starke Date: Fri, 11 Oct 2019 22:13:55 -0700 Subject: [PATCH] Added Exception to for describe_container_instances to match aws api --- moto/ecs/models.py | 2 ++ tests/test_ecs/test_ecs_boto3.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/moto/ecs/models.py b/moto/ecs/models.py index 9416db84a..5aa9ae2cb 100644 --- a/moto/ecs/models.py +++ b/moto/ecs/models.py @@ -790,6 +790,8 @@ class EC2ContainerServiceBackend(BaseBackend): cluster_name = cluster_str.split('/')[-1] if cluster_name not in self.clusters: raise Exception("{0} is not a cluster".format(cluster_name)) + if not list_container_instance_ids: + raise JsonRESTError('InvalidParameterException', 'Container instance cannot be empty') failures = [] container_instance_objects = [] for container_instance_id in list_container_instance_ids: diff --git a/tests/test_ecs/test_ecs_boto3.py b/tests/test_ecs/test_ecs_boto3.py index 1b501f519..16d7a4d0d 100644 --- a/tests/test_ecs/test_ecs_boto3.py +++ b/tests/test_ecs/test_ecs_boto3.py @@ -889,6 +889,12 @@ def test_describe_container_instances(): instance.keys().should.contain('runningTasksCount') instance.keys().should.contain('pendingTasksCount') + with assert_raises(ClientError) as e: + ecs_client.describe_container_instances( + cluster=test_cluster_name, + containerInstances=[] + ) + @mock_ec2 @mock_ecs