Finish porting from nose to pytest.
This commit is contained in:
parent
77dc60ea97
commit
ea489bce6c
72 changed files with 1289 additions and 1280 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
# Ensure 'pytest.raises' context manager support for Python 2.6
|
||||
import pytest
|
||||
|
||||
import boto
|
||||
|
|
@ -22,9 +22,9 @@ def test_eip_allocate_classic():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
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(
|
||||
ex.value.error_code.should.equal("DryRunOperation")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the AllocateAddress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -36,9 +36,9 @@ def test_eip_allocate_classic():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
standard.release(dry_run=True)
|
||||
ex.exception.error_code.should.equal("DryRunOperation")
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal(
|
||||
ex.value.error_code.should.equal("DryRunOperation")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the ReleaseAddress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -53,9 +53,9 @@ def test_eip_allocate_vpc():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
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(
|
||||
ex.value.error_code.should.equal("DryRunOperation")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the AllocateAddress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -85,9 +85,9 @@ def test_eip_allocate_invalid_domain():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.allocate_address(domain="bogus")
|
||||
cm.exception.code.should.equal("InvalidParameterValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidParameterValue")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -103,17 +103,17 @@ def test_eip_associate_classic():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_address(public_ip=eip.public_ip)
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("MissingParameter")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
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(
|
||||
ex.value.error_code.should.equal("DryRunOperation")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the AssociateAddress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -124,9 +124,9 @@ def test_eip_associate_classic():
|
|||
|
||||
with pytest.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(
|
||||
ex.value.error_code.should.equal("DryRunOperation")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the DisAssociateAddress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -154,9 +154,9 @@ def test_eip_associate_vpc():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_address(allocation_id=eip.allocation_id)
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("MissingParameter")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
conn.associate_address(instance_id=instance.id, allocation_id=eip.allocation_id)
|
||||
# no .update() on address ):
|
||||
|
|
@ -170,9 +170,9 @@ def test_eip_associate_vpc():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
eip.release(dry_run=True)
|
||||
ex.exception.error_code.should.equal("DryRunOperation")
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal(
|
||||
ex.value.error_code.should.equal("DryRunOperation")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the ReleaseAddress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -242,9 +242,9 @@ def test_eip_associate_network_interface():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_address(network_interface_id=eni.id)
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("MissingParameter")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
conn.associate_address(network_interface_id=eni.id, allocation_id=eip.allocation_id)
|
||||
# no .update() on address ):
|
||||
|
|
@ -279,9 +279,9 @@ def test_eip_reassociate():
|
|||
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
|
||||
cm.value.code.should.equal("Resource.AlreadyAssociated")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
conn.associate_address.when.called_with(
|
||||
instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=True
|
||||
|
|
@ -313,9 +313,9 @@ def test_eip_reassociate_nic():
|
|||
# Different ID detects resource association
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
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
|
||||
cm.value.code.should.equal("Resource.AlreadyAssociated")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.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
|
||||
|
|
@ -337,9 +337,9 @@ def test_eip_associate_invalid_args():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_address(instance_id=instance.id)
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("MissingParameter")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
instance.terminate()
|
||||
|
||||
|
|
@ -351,9 +351,9 @@ def test_eip_disassociate_bogus_association():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.disassociate_address(association_id="bogus")
|
||||
cm.exception.code.should.equal("InvalidAssociationID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAssociationID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -363,9 +363,9 @@ def test_eip_release_bogus_eip():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.release_address(allocation_id="bogus")
|
||||
cm.exception.code.should.equal("InvalidAllocationID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAllocationID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -375,9 +375,9 @@ def test_eip_disassociate_arg_error():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.disassociate_address()
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("MissingParameter")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -387,9 +387,9 @@ def test_eip_release_arg_error():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.release_address()
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("MissingParameter")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -439,9 +439,9 @@ def test_eip_describe_none():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_addresses(addresses=["256.256.256.256"])
|
||||
cm.exception.code.should.equal("InvalidAddress.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAddress.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue