Port test suite from nose to pytest.
This just eliminates all errors on the tests collection. Elimination of failures is left to the next commit.
This commit is contained in:
parent
47dbad291e
commit
77dc60ea97
146 changed files with 1172 additions and 1277 deletions
|
|
@ -1,8 +1,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
import tests.backport_assert_raises
|
||||
from nose.tools import assert_raises
|
||||
import pytest
|
||||
|
||||
import boto
|
||||
import boto3
|
||||
|
|
@ -21,7 +20,7 @@ def test_eip_allocate_classic():
|
|||
"""Allocate/release Classic EIP"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
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)
|
||||
|
|
@ -35,7 +34,7 @@ def test_eip_allocate_classic():
|
|||
standard.instance_id.should.be.none
|
||||
standard.domain.should.be.equal("standard")
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
standard.release(dry_run=True)
|
||||
ex.exception.error_code.should.equal("DryRunOperation")
|
||||
ex.exception.status.should.equal(400)
|
||||
|
|
@ -52,7 +51,7 @@ def test_eip_allocate_vpc():
|
|||
"""Allocate/release VPC EIP"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
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)
|
||||
|
|
@ -84,7 +83,7 @@ def test_eip_allocate_invalid_domain():
|
|||
"""Allocate EIP invalid domain"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.allocate_address(domain="bogus")
|
||||
cm.exception.code.should.equal("InvalidParameterValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
|
|
@ -102,13 +101,13 @@ def test_eip_associate_classic():
|
|||
eip = conn.allocate_address()
|
||||
eip.instance_id.should.be.none
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.associate_address(
|
||||
instance_id=instance.id, public_ip=eip.public_ip, dry_run=True
|
||||
)
|
||||
|
|
@ -123,7 +122,7 @@ def test_eip_associate_classic():
|
|||
eip = conn.get_all_addresses(addresses=[eip.public_ip])[0]
|
||||
eip.instance_id.should.be.equal(instance.id)
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
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)
|
||||
|
|
@ -153,7 +152,7 @@ def test_eip_associate_vpc():
|
|||
eip = conn.allocate_address(domain="vpc")
|
||||
eip.instance_id.should.be.none
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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)
|
||||
|
|
@ -169,7 +168,7 @@ def test_eip_associate_vpc():
|
|||
eip.instance_id.should.be.equal("")
|
||||
eip.association_id.should.be.none
|
||||
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
eip.release(dry_run=True)
|
||||
ex.exception.error_code.should.equal("DryRunOperation")
|
||||
ex.exception.status.should.equal(400)
|
||||
|
|
@ -241,7 +240,7 @@ def test_eip_associate_network_interface():
|
|||
eip = conn.allocate_address(domain="vpc")
|
||||
eip.network_interface_id.should.be.none
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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)
|
||||
|
|
@ -276,7 +275,7 @@ def test_eip_reassociate():
|
|||
conn.associate_address(instance_id=instance1.id, public_ip=eip.public_ip)
|
||||
|
||||
# Different ID detects resource association
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_address(
|
||||
instance_id=instance2.id, public_ip=eip.public_ip, allow_reassociation=False
|
||||
)
|
||||
|
|
@ -312,7 +311,7 @@ def test_eip_reassociate_nic():
|
|||
conn.associate_address(network_interface_id=eni1.id, public_ip=eip.public_ip)
|
||||
|
||||
# Different ID detects resource association
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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)
|
||||
|
|
@ -336,7 +335,7 @@ def test_eip_associate_invalid_args():
|
|||
|
||||
eip = conn.allocate_address()
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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)
|
||||
|
|
@ -350,7 +349,7 @@ def test_eip_disassociate_bogus_association():
|
|||
"""Disassociate bogus EIP"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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)
|
||||
|
|
@ -362,7 +361,7 @@ def test_eip_release_bogus_eip():
|
|||
"""Release bogus EIP"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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)
|
||||
|
|
@ -374,7 +373,7 @@ def test_eip_disassociate_arg_error():
|
|||
"""Invalid arguments disassociate address"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.disassociate_address()
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
|
|
@ -386,7 +385,7 @@ def test_eip_release_arg_error():
|
|||
"""Invalid arguments release address"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.release_address()
|
||||
cm.exception.code.should.equal("MissingParameter")
|
||||
cm.exception.status.should.equal(400)
|
||||
|
|
@ -438,7 +437,7 @@ def test_eip_describe_none():
|
|||
"""Error when search for bogus IP"""
|
||||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
|
||||
with assert_raises(EC2ResponseError) as cm:
|
||||
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue