fix TargetGroupNnotFoundError is not definied correctly (#1099)

This commit is contained in:
Toshiya Kawasaki 2017-09-08 03:25:59 +09:00 committed by Jack Danger
parent 76b7101bc3
commit 8f0e2e7954
2 changed files with 41 additions and 1 deletions

View File

@ -42,7 +42,7 @@ class SubnetNotFoundError(ELBClientError):
class TargetGroupNotFoundError(ELBClientError):
def __init__(self):
super(TooManyTagsError, self).__init__(
super(TargetGroupNotFoundError, self).__init__(
"TargetGroupNotFound",
"The specified target group does not exist.")

View File

@ -861,3 +861,43 @@ def test_handle_listener_rules():
'Type': 'forward'
}]
)
@mock_elbv2
@mock_ec2
def test_describe_invalid_target_group():
conn = boto3.client('elbv2', region_name='us-east-1')
ec2 = boto3.resource('ec2', region_name='us-east-1')
security_group = ec2.create_security_group(GroupName='a-security-group', Description='First One')
vpc = ec2.create_vpc(CidrBlock='172.28.7.0/24', InstanceTenancy='default')
subnet1 = ec2.create_subnet(VpcId=vpc.id, CidrBlock='172.28.7.192/26', AvailabilityZone='us-east-1a')
subnet2 = ec2.create_subnet(VpcId=vpc.id, CidrBlock='172.28.7.192/26', AvailabilityZone='us-east-1b')
response = conn.create_load_balancer(
Name='my-lb',
Subnets=[subnet1.id, subnet2.id],
SecurityGroups=[security_group.id],
Scheme='internal',
Tags=[{'Key': 'key_name', 'Value': 'a_value'}])
load_balancer_arn = response.get('LoadBalancers')[0].get('LoadBalancerArn')
response = conn.create_target_group(
Name='a-target',
Protocol='HTTP',
Port=8080,
VpcId=vpc.id,
HealthCheckProtocol='HTTP',
HealthCheckPort='8080',
HealthCheckPath='/',
HealthCheckIntervalSeconds=5,
HealthCheckTimeoutSeconds=5,
HealthyThresholdCount=5,
UnhealthyThresholdCount=2,
Matcher={'HttpCode': '200'})
target_group = response.get('TargetGroups')[0]
# Check error raises correctly
with assert_raises(ClientError):
conn.describe_target_groups(Names=['invalid'])