diff --git a/moto/elbv2/models.py b/moto/elbv2/models.py index b30ab5764..87e6d7738 100644 --- a/moto/elbv2/models.py +++ b/moto/elbv2/models.py @@ -354,7 +354,7 @@ class ELBv2Backend(BaseBackend): matched = [] for name in names: found = None - for target_group in self.target_groups: + for target_group in self.target_groups.values(): if target_group.name == name: found = target_group if not found: diff --git a/tests/test_elbv2/test_elbv2.py b/tests/test_elbv2/test_elbv2.py index a37eaa9bc..4a47397ef 100644 --- a/tests/test_elbv2/test_elbv2.py +++ b/tests/test_elbv2/test_elbv2.py @@ -485,6 +485,12 @@ def test_target_group_attributes(): response.get('TargetGroups').should.have.length_of(1) target_group_arn = target_group['TargetGroupArn'] + # check if Names filter works + response = conn.describe_target_groups(Names=[]) + response = conn.describe_target_groups(Names=['a-target']) + response.get('TargetGroups').should.have.length_of(1) + target_group_arn = target_group['TargetGroupArn'] + # The attributes should start with the two defaults response = conn.describe_target_group_attributes(TargetGroupArn=target_group_arn) response['Attributes'].should.have.length_of(2)