Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -24,7 +24,8 @@ def test_eip_allocate_classic():
|
|||
standard = conn.allocate_address(dry_run=True)
|
||||
ex.exception.error_code.should.equal('DryRunOperation')
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the AllocateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
ex.exception.message.should.equal(
|
||||
'An error occurred (DryRunOperation) when calling the AllocateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
|
||||
standard = conn.allocate_address()
|
||||
standard.should.be.a(boto.ec2.address.Address)
|
||||
|
|
@ -36,7 +37,8 @@ def test_eip_allocate_classic():
|
|||
standard.release(dry_run=True)
|
||||
ex.exception.error_code.should.equal('DryRunOperation')
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the ReleaseAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
ex.exception.message.should.equal(
|
||||
'An error occurred (DryRunOperation) when calling the ReleaseAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
|
||||
standard.release()
|
||||
standard.should_not.be.within(conn.get_all_addresses())
|
||||
|
|
@ -51,7 +53,8 @@ def test_eip_allocate_vpc():
|
|||
vpc = conn.allocate_address(domain="vpc", dry_run=True)
|
||||
ex.exception.error_code.should.equal('DryRunOperation')
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the AllocateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
ex.exception.message.should.equal(
|
||||
'An error occurred (DryRunOperation) when calling the AllocateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
|
||||
vpc = conn.allocate_address(domain="vpc")
|
||||
vpc.should.be.a(boto.ec2.address.Address)
|
||||
|
|
@ -90,23 +93,28 @@ def test_eip_associate_classic():
|
|||
cm.exception.request_id.should_not.be.none
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
conn.associate_address(instance_id=instance.id, public_ip=eip.public_ip, dry_run=True)
|
||||
conn.associate_address(instance_id=instance.id,
|
||||
public_ip=eip.public_ip, dry_run=True)
|
||||
ex.exception.error_code.should.equal('DryRunOperation')
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the AssociateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
ex.exception.message.should.equal(
|
||||
'An error occurred (DryRunOperation) when calling the AssociateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
|
||||
conn.associate_address(instance_id=instance.id, public_ip=eip.public_ip)
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0] # no .update() on address ):
|
||||
# no .update() on address ):
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0]
|
||||
eip.instance_id.should.be.equal(instance.id)
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
conn.disassociate_address(public_ip=eip.public_ip, dry_run=True)
|
||||
ex.exception.error_code.should.equal('DryRunOperation')
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the DisAssociateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
ex.exception.message.should.equal(
|
||||
'An error occurred (DryRunOperation) when calling the DisAssociateAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
|
||||
conn.disassociate_address(public_ip=eip.public_ip)
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0] # no .update() on address ):
|
||||
# no .update() on address ):
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0]
|
||||
eip.instance_id.should.be.equal(u'')
|
||||
eip.release()
|
||||
eip.should_not.be.within(conn.get_all_addresses())
|
||||
|
|
@ -114,6 +122,7 @@ def test_eip_associate_classic():
|
|||
|
||||
instance.terminate()
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
def test_eip_associate_vpc():
|
||||
"""Associate/Disassociate EIP to VPC instance"""
|
||||
|
|
@ -131,11 +140,14 @@ def test_eip_associate_vpc():
|
|||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
|
||||
conn.associate_address(instance_id=instance.id, allocation_id=eip.allocation_id)
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0] # no .update() on address ):
|
||||
conn.associate_address(instance_id=instance.id,
|
||||
allocation_id=eip.allocation_id)
|
||||
# no .update() on address ):
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0]
|
||||
eip.instance_id.should.be.equal(instance.id)
|
||||
conn.disassociate_address(association_id=eip.association_id)
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0] # no .update() on address ):
|
||||
# no .update() on address ):
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0]
|
||||
eip.instance_id.should.be.equal(u'')
|
||||
eip.association_id.should.be.none
|
||||
|
||||
|
|
@ -143,13 +155,15 @@ def test_eip_associate_vpc():
|
|||
eip.release(dry_run=True)
|
||||
ex.exception.error_code.should.equal('DryRunOperation')
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the ReleaseAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
ex.exception.message.should.equal(
|
||||
'An error occurred (DryRunOperation) when calling the ReleaseAddress operation: Request would have succeeded, but DryRun flag is set')
|
||||
|
||||
eip.release()
|
||||
eip = None
|
||||
|
||||
instance.terminate()
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_eip_boto3_vpc_association():
|
||||
"""Associate EIP to VPC instance in a new subnet with boto3"""
|
||||
|
|
@ -157,7 +171,7 @@ def test_eip_boto3_vpc_association():
|
|||
client = boto3.client('ec2', region_name='us-west-1')
|
||||
vpc_res = client.create_vpc(CidrBlock='10.0.0.0/24')
|
||||
subnet_res = client.create_subnet(
|
||||
VpcId=vpc_res['Vpc']['VpcId'], CidrBlock='10.0.0.0/24')
|
||||
VpcId=vpc_res['Vpc']['VpcId'], CidrBlock='10.0.0.0/24')
|
||||
instance = service.create_instances(**{
|
||||
'InstanceType': 't2.micro',
|
||||
'ImageId': 'ami-test',
|
||||
|
|
@ -192,17 +206,21 @@ def test_eip_associate_network_interface():
|
|||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
|
||||
conn.associate_address(network_interface_id=eni.id, allocation_id=eip.allocation_id)
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0] # no .update() on address ):
|
||||
conn.associate_address(network_interface_id=eni.id,
|
||||
allocation_id=eip.allocation_id)
|
||||
# no .update() on address ):
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0]
|
||||
eip.network_interface_id.should.be.equal(eni.id)
|
||||
|
||||
conn.disassociate_address(association_id=eip.association_id)
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0] # no .update() on address ):
|
||||
# no .update() on address ):
|
||||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0]
|
||||
eip.network_interface_id.should.be.equal(u'')
|
||||
eip.association_id.should.be.none
|
||||
eip.release()
|
||||
eip = None
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
def test_eip_reassociate():
|
||||
"""reassociate EIP"""
|
||||
|
|
@ -219,12 +237,14 @@ def test_eip_reassociate():
|
|||
|
||||
# Different ID detects resource association
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
conn.associate_address(instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=False)
|
||||
conn.associate_address(
|
||||
instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=False)
|
||||
cm.exception.code.should.equal('Resource.AlreadyAssociated')
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
|
||||
conn.associate_address.when.called_with(instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=True).should_not.throw(EC2ResponseError)
|
||||
conn.associate_address.when.called_with(
|
||||
instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=True).should_not.throw(EC2ResponseError)
|
||||
|
||||
eip.release()
|
||||
eip = None
|
||||
|
|
@ -232,6 +252,7 @@ def test_eip_reassociate():
|
|||
instance1.terminate()
|
||||
instance2.terminate()
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
def test_eip_reassociate_nic():
|
||||
"""reassociate EIP"""
|
||||
|
|
@ -243,23 +264,28 @@ def test_eip_reassociate_nic():
|
|||
eni2 = conn.create_network_interface(subnet.id)
|
||||
|
||||
eip = conn.allocate_address()
|
||||
conn.associate_address(network_interface_id=eni1.id, public_ip=eip.public_ip)
|
||||
conn.associate_address(network_interface_id=eni1.id,
|
||||
public_ip=eip.public_ip)
|
||||
|
||||
# Same ID is idempotent
|
||||
conn.associate_address(network_interface_id=eni1.id, public_ip=eip.public_ip)
|
||||
conn.associate_address(network_interface_id=eni1.id,
|
||||
public_ip=eip.public_ip)
|
||||
|
||||
# Different ID detects resource association
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
conn.associate_address(network_interface_id=eni2.id, public_ip=eip.public_ip)
|
||||
conn.associate_address(
|
||||
network_interface_id=eni2.id, public_ip=eip.public_ip)
|
||||
cm.exception.code.should.equal('Resource.AlreadyAssociated')
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
|
||||
conn.associate_address.when.called_with(network_interface_id=eni2.id, public_ip=eip.public_ip, allow_reassociation=True).should_not.throw(EC2ResponseError)
|
||||
conn.associate_address.when.called_with(
|
||||
network_interface_id=eni2.id, public_ip=eip.public_ip, allow_reassociation=True).should_not.throw(EC2ResponseError)
|
||||
|
||||
eip.release()
|
||||
eip = None
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
def test_eip_associate_invalid_args():
|
||||
"""Associate EIP, invalid args """
|
||||
|
|
@ -290,6 +316,7 @@ def test_eip_disassociate_bogus_association():
|
|||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
def test_eip_release_bogus_eip():
|
||||
"""Release bogus EIP"""
|
||||
|
|
@ -334,7 +361,7 @@ def test_eip_describe():
|
|||
number_of_classic_ips = 2
|
||||
number_of_vpc_ips = 2
|
||||
|
||||
#allocate some IPs
|
||||
# allocate some IPs
|
||||
for _ in range(number_of_classic_ips):
|
||||
eips.append(conn.allocate_address())
|
||||
for _ in range(number_of_vpc_ips):
|
||||
|
|
@ -344,19 +371,22 @@ def test_eip_describe():
|
|||
# Can we find each one individually?
|
||||
for eip in eips:
|
||||
if eip.allocation_id:
|
||||
lookup_addresses = conn.get_all_addresses(allocation_ids=[eip.allocation_id])
|
||||
lookup_addresses = conn.get_all_addresses(
|
||||
allocation_ids=[eip.allocation_id])
|
||||
else:
|
||||
lookup_addresses = conn.get_all_addresses(addresses=[eip.public_ip])
|
||||
lookup_addresses = conn.get_all_addresses(
|
||||
addresses=[eip.public_ip])
|
||||
len(lookup_addresses).should.be.equal(1)
|
||||
lookup_addresses[0].public_ip.should.be.equal(eip.public_ip)
|
||||
|
||||
# Can we find first two when we search for them?
|
||||
lookup_addresses = conn.get_all_addresses(addresses=[eips[0].public_ip, eips[1].public_ip])
|
||||
lookup_addresses = conn.get_all_addresses(
|
||||
addresses=[eips[0].public_ip, eips[1].public_ip])
|
||||
len(lookup_addresses).should.be.equal(2)
|
||||
lookup_addresses[0].public_ip.should.be.equal(eips[0].public_ip)
|
||||
lookup_addresses[1].public_ip.should.be.equal(eips[1].public_ip)
|
||||
|
||||
#Release all IPs
|
||||
# Release all IPs
|
||||
for eip in eips:
|
||||
eip.release()
|
||||
len(conn.get_all_addresses()).should.be.equal(0)
|
||||
|
|
@ -372,4 +402,3 @@ def test_eip_describe_none():
|
|||
cm.exception.code.should.equal('InvalidAddress.NotFound')
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue