Finish porting from nose to pytest.

This commit is contained in:
Matěj Cepl 2020-10-06 08:04:09 +02:00
commit ea489bce6c
72 changed files with 1289 additions and 1280 deletions

View file

@ -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 re
@ -29,9 +29,9 @@ def test_igw_create():
with pytest.raises(EC2ResponseError) as ex:
igw = conn.create_internet_gateway(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 CreateInternetGateway operation: Request would have succeeded, but DryRun flag is set"
)
@ -52,9 +52,9 @@ def test_igw_attach():
with pytest.raises(EC2ResponseError) as ex:
conn.attach_internet_gateway(igw.id, vpc.id, 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 AttachInternetGateway operation: Request would have succeeded, but DryRun flag is set"
)
@ -72,9 +72,9 @@ def test_igw_attach_bad_vpc():
with pytest.raises(EC2ResponseError) as cm:
conn.attach_internet_gateway(igw.id, BAD_VPC)
cm.exception.code.should.equal("InvalidVpcID.NotFound")
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
cm.value.code.should.equal("InvalidVpcID.NotFound")
cm.value.status.should.equal(400)
cm.value.request_id.should_not.be.none
@mock_ec2_deprecated
@ -88,9 +88,9 @@ def test_igw_attach_twice():
with pytest.raises(EC2ResponseError) as cm:
conn.attach_internet_gateway(igw.id, vpc2.id)
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
@mock_ec2_deprecated
@ -103,9 +103,9 @@ def test_igw_detach():
with pytest.raises(EC2ResponseError) as ex:
conn.detach_internet_gateway(igw.id, vpc.id, 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 DetachInternetGateway operation: Request would have succeeded, but DryRun flag is set"
)
@ -125,9 +125,9 @@ def test_igw_detach_wrong_vpc():
with pytest.raises(EC2ResponseError) as cm:
conn.detach_internet_gateway(igw.id, vpc2.id)
cm.exception.code.should.equal("Gateway.NotAttached")
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
cm.value.code.should.equal("Gateway.NotAttached")
cm.value.status.should.equal(400)
cm.value.request_id.should_not.be.none
@mock_ec2_deprecated
@ -140,9 +140,9 @@ def test_igw_detach_invalid_vpc():
with pytest.raises(EC2ResponseError) as cm:
conn.detach_internet_gateway(igw.id, BAD_VPC)
cm.exception.code.should.equal("Gateway.NotAttached")
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
cm.value.code.should.equal("Gateway.NotAttached")
cm.value.status.should.equal(400)
cm.value.request_id.should_not.be.none
@mock_ec2_deprecated
@ -154,9 +154,9 @@ def test_igw_detach_unattached():
with pytest.raises(EC2ResponseError) as cm:
conn.detach_internet_gateway(igw.id, vpc.id)
cm.exception.code.should.equal("Gateway.NotAttached")
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
cm.value.code.should.equal("Gateway.NotAttached")
cm.value.status.should.equal(400)
cm.value.request_id.should_not.be.none
@mock_ec2_deprecated
@ -170,9 +170,9 @@ def test_igw_delete():
with pytest.raises(EC2ResponseError) as ex:
conn.delete_internet_gateway(igw.id, 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 DeleteInternetGateway operation: Request would have succeeded, but DryRun flag is set"
)
@ -190,9 +190,9 @@ def test_igw_delete_attached():
with pytest.raises(EC2ResponseError) as cm:
conn.delete_internet_gateway(igw.id)
cm.exception.code.should.equal("DependencyViolation")
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
cm.value.code.should.equal("DependencyViolation")
cm.value.status.should.equal(400)
cm.value.request_id.should_not.be.none
@mock_ec2_deprecated
@ -210,9 +210,9 @@ def test_igw_describe_bad_id():
conn = boto.connect_vpc("the_key", "the_secret")
with pytest.raises(EC2ResponseError) as cm:
conn.get_all_internet_gateways([BAD_IGW])
cm.exception.code.should.equal("InvalidInternetGatewayID.NotFound")
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
cm.value.code.should.equal("InvalidInternetGatewayID.NotFound")
cm.value.status.should.equal(400)
cm.value.request_id.should_not.be.none
@mock_ec2_deprecated