Finish porting from nose to pytest.
This commit is contained in:
parent
77dc60ea97
commit
ea489bce6c
72 changed files with 1289 additions and 1280 deletions
|
|
@ -6,7 +6,7 @@ import boto3
|
|||
from boto.exception import EC2ResponseError
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
# Ensure 'pytest.raises' context manager support for Python 2.6
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
|
|
@ -31,9 +31,9 @@ def test_ami_create_and_delete():
|
|||
image_id = conn.create_image(
|
||||
instance.id, "test-ami", "this is a test ami", 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 CreateImage operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -78,9 +78,9 @@ def test_ami_create_and_delete():
|
|||
# Deregister
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
success = conn.deregister_image(image_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 DeregisterImage operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -89,9 +89,9 @@ def test_ami_create_and_delete():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.deregister_image(image_id)
|
||||
cm.exception.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@requires_boto_gte("2.14.0")
|
||||
|
|
@ -120,9 +120,9 @@ def test_ami_copy():
|
|||
"this is a test copy ami",
|
||||
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 CopyImage operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -159,9 +159,9 @@ def test_ami_copy():
|
|||
"test-copy-ami",
|
||||
"this is a test copy ami",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Copy from non-existent source region.
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
|
|
@ -171,9 +171,9 @@ def test_ami_copy():
|
|||
conn.copy_image(
|
||||
invalid_region, source_image.id, "test-copy-ami", "this is a test copy ami"
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
@ -210,9 +210,9 @@ def test_ami_tagging():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
image.add_tag("a key", "some value", 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 CreateTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -235,9 +235,9 @@ def test_ami_create_from_missing_instance():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_image(*args)
|
||||
cm.exception.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -355,9 +355,9 @@ def test_getting_missing_ami():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_image("ami-missing")
|
||||
cm.exception.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -366,9 +366,9 @@ def test_getting_malformed_ami():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_image("foo-missing")
|
||||
cm.exception.code.should.equal("InvalidAMIID.Malformed")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIID.Malformed")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -401,9 +401,9 @@ def test_ami_attribute_group_permissions():
|
|||
# Add 'all' group and confirm
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.modify_image_attribute(**dict(ADD_GROUP_ARGS, **{"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 ModifyImageAttribute operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -682,9 +682,9 @@ def test_ami_attribute_error_cases():
|
|||
conn.modify_image_attribute(
|
||||
image.id, attribute="launchPermission", operation="add", groups="everyone"
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Add with user ID that isn't an integer.
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
|
|
@ -694,9 +694,9 @@ def test_ami_attribute_error_cases():
|
|||
operation="add",
|
||||
user_ids="12345678901A",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Add with user ID that is > length 12.
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
|
|
@ -706,9 +706,9 @@ def test_ami_attribute_error_cases():
|
|||
operation="add",
|
||||
user_ids="1234567890123",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Add with user ID that is < length 12.
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
|
|
@ -718,9 +718,9 @@ def test_ami_attribute_error_cases():
|
|||
operation="add",
|
||||
user_ids="12345678901",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Add with one invalid user ID among other valid IDs, ensure no
|
||||
# partial changes.
|
||||
|
|
@ -731,9 +731,9 @@ def test_ami_attribute_error_cases():
|
|||
operation="add",
|
||||
user_ids=["123456789011", "foo", "123456789022"],
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
attributes = conn.get_image_attribute(image.id, attribute="launchPermission")
|
||||
attributes.attrs.should.have.length_of(0)
|
||||
|
|
@ -743,9 +743,9 @@ def test_ami_attribute_error_cases():
|
|||
conn.modify_image_attribute(
|
||||
"ami-abcd1234", attribute="launchPermission", operation="add", groups="all"
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Remove with invalid image ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
|
|
@ -755,9 +755,9 @@ def test_ami_attribute_error_cases():
|
|||
operation="remove",
|
||||
groups="all",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
|
|||
|
|
@ -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 boto3
|
||||
|
|
@ -34,9 +34,9 @@ def test_dhcp_options_associate_invalid_dhcp_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_dhcp_options("foo", vpc.id)
|
||||
cm.exception.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -47,9 +47,9 @@ def test_dhcp_options_associate_invalid_vpc_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_dhcp_options(dhcp_options.id, "foo")
|
||||
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
|
||||
|
|
@ -65,17 +65,17 @@ def test_dhcp_options_delete_with_vpc():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_dhcp_options(dhcp_options_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
|
||||
|
||||
vpc.delete()
|
||||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_dhcp_options([dhcp_options_id])
|
||||
cm.exception.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -101,15 +101,15 @@ def test_create_dhcp_options_invalid_options():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_dhcp_options(ntp_servers=servers)
|
||||
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
|
||||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_dhcp_options(netbios_node_type="0")
|
||||
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
|
||||
|
|
@ -132,9 +132,9 @@ def test_describe_dhcp_options_invalid_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_dhcp_options(["1"])
|
||||
cm.exception.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -150,9 +150,9 @@ def test_delete_dhcp_options():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_dhcp_options([dhcp_option.id])
|
||||
cm.exception.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -163,9 +163,9 @@ def test_delete_dhcp_options_invalid_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_dhcp_options("dopt-abcd1234")
|
||||
cm.exception.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidDhcpOptionID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -176,9 +176,9 @@ def test_delete_dhcp_options_malformed_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_dhcp_options("foo-abcd1234")
|
||||
cm.exception.code.should.equal("InvalidDhcpOptionsId.Malformed")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidDhcpOptionsId.Malformed")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
from moto.ec2 import ec2_backends
|
||||
|
|
@ -32,9 +32,9 @@ def test_create_and_delete_volume():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
volume.delete(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 DeleteVolume operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -47,9 +47,9 @@ def test_create_and_delete_volume():
|
|||
# Deleting something that was already deleted should throw an error
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
volume.delete()
|
||||
cm.exception.code.should.equal("InvalidVolume.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidVolume.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -71,11 +71,11 @@ def test_delete_attached_volume():
|
|||
|
||||
# attempt to delete volume
|
||||
# assert raises VolumeInUseError
|
||||
with assert_raises(EC2ResponseError) as ex:
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
volume.delete()
|
||||
ex.exception.error_code.should.equal("VolumeInUse")
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal(
|
||||
ex.value.error_code.should.equal("VolumeInUse")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal(
|
||||
"Volume {0} is currently attached to {1}".format(volume.id, instance.id)
|
||||
)
|
||||
|
||||
|
|
@ -96,9 +96,9 @@ def test_create_encrypted_volume_dryrun():
|
|||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.create_volume(80, "us-east-1a", encrypted=True, 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 CreateVolume operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -110,9 +110,9 @@ def test_create_encrypted_volume():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.create_volume(80, "us-east-1a", encrypted=True, 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 CreateVolume operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -135,9 +135,9 @@ def test_filter_volume_by_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_volumes(volume_ids=["vol-does_not_exist"])
|
||||
cm.exception.code.should.equal("InvalidVolume.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidVolume.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -260,9 +260,9 @@ def test_volume_attach_and_detach():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
volume.attach(instance.id, "/dev/sdh", 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 AttachVolume operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -276,9 +276,9 @@ def test_volume_attach_and_detach():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
volume.detach(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 DetachVolume operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -289,21 +289,21 @@ def test_volume_attach_and_detach():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm1:
|
||||
volume.attach("i-1234abcd", "/dev/sdh")
|
||||
cm1.exception.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm1.exception.status.should.equal(400)
|
||||
cm1.exception.request_id.should_not.be.none
|
||||
cm1.value.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm1.value.status.should.equal(400)
|
||||
cm1.value.request_id.should_not.be.none
|
||||
|
||||
with pytest.raises(EC2ResponseError) as cm2:
|
||||
conn.detach_volume(volume.id, instance.id, "/dev/sdh")
|
||||
cm2.exception.code.should.equal("InvalidAttachment.NotFound")
|
||||
cm2.exception.status.should.equal(400)
|
||||
cm2.exception.request_id.should_not.be.none
|
||||
cm2.value.code.should.equal("InvalidAttachment.NotFound")
|
||||
cm2.value.status.should.equal(400)
|
||||
cm2.value.request_id.should_not.be.none
|
||||
|
||||
with pytest.raises(EC2ResponseError) as cm3:
|
||||
conn.detach_volume(volume.id, "i-1234abcd", "/dev/sdh")
|
||||
cm3.exception.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm3.exception.status.should.equal(400)
|
||||
cm3.exception.request_id.should_not.be.none
|
||||
cm3.value.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm3.value.status.should.equal(400)
|
||||
cm3.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -313,9 +313,9 @@ def test_create_snapshot():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
snapshot = volume.create_snapshot("a dryrun snapshot", 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 CreateSnapshot operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -341,9 +341,9 @@ def test_create_snapshot():
|
|||
# Deleting something that was already deleted should throw an error
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
snapshot.delete()
|
||||
cm.exception.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -383,9 +383,9 @@ def test_filter_snapshot_by_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_snapshots(snapshot_ids=["snap-does_not_exist"])
|
||||
cm.exception.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -485,9 +485,9 @@ def test_snapshot_attribute():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.modify_snapshot_attribute(**dict(ADD_GROUP_ARGS, **{"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 ModifySnapshotAttribute operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -507,9 +507,9 @@ def test_snapshot_attribute():
|
|||
# Remove 'all' group and confirm
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.modify_snapshot_attribute(**dict(REMOVE_GROUP_ARGS, **{"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 ModifySnapshotAttribute operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -533,9 +533,9 @@ def test_snapshot_attribute():
|
|||
operation="add",
|
||||
groups="everyone",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Add with invalid snapshot ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
|
|
@ -545,9 +545,9 @@ def test_snapshot_attribute():
|
|||
operation="add",
|
||||
groups="all",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Remove with invalid snapshot ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
|
|
@ -557,9 +557,9 @@ def test_snapshot_attribute():
|
|||
operation="remove",
|
||||
groups="all",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidSnapshot.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
@ -594,12 +594,12 @@ def test_modify_snapshot_attribute():
|
|||
}
|
||||
|
||||
# Add 'all' group and confirm
|
||||
with assert_raises(ClientError) as cm:
|
||||
with pytest.raises(ClientError) as cm:
|
||||
ec2_client.modify_snapshot_attribute(**dict(ADD_GROUP_ARGS, **{"DryRun": True}))
|
||||
|
||||
cm.exception.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
cm.exception.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
cm.value.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
cm.value.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
|
||||
ec2_client.modify_snapshot_attribute(**ADD_GROUP_ARGS)
|
||||
|
||||
|
|
@ -619,13 +619,13 @@ def test_modify_snapshot_attribute():
|
|||
], "This snapshot should have public group permissions."
|
||||
|
||||
# Remove 'all' group and confirm
|
||||
with assert_raises(ClientError) as ex:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
ec2_client.modify_snapshot_attribute(
|
||||
**dict(REMOVE_GROUP_ARGS, **{"DryRun": True})
|
||||
)
|
||||
cm.exception.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
cm.exception.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
cm.value.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
cm.value.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
|
||||
ec2_client.modify_snapshot_attribute(**REMOVE_GROUP_ARGS)
|
||||
|
||||
|
|
@ -645,40 +645,40 @@ def test_modify_snapshot_attribute():
|
|||
], "This snapshot should have no permissions."
|
||||
|
||||
# Error: Add with group != 'all'
|
||||
with assert_raises(ClientError) as cm:
|
||||
with pytest.raises(ClientError) as cm:
|
||||
ec2_client.modify_snapshot_attribute(
|
||||
SnapshotId=snapshot.id,
|
||||
Attribute="createVolumePermission",
|
||||
OperationType="add",
|
||||
GroupNames=["everyone"],
|
||||
)
|
||||
cm.exception.response["Error"]["Code"].should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.exception.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
cm.value.response["Error"]["Code"].should.equal("InvalidAMIAttributeItemValue")
|
||||
cm.value.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
|
||||
# Error: Add with invalid snapshot ID
|
||||
with assert_raises(ClientError) as cm:
|
||||
with pytest.raises(ClientError) as cm:
|
||||
ec2_client.modify_snapshot_attribute(
|
||||
SnapshotId="snapshot-abcd1234",
|
||||
Attribute="createVolumePermission",
|
||||
OperationType="add",
|
||||
GroupNames=["all"],
|
||||
)
|
||||
cm.exception.response["Error"]["Code"].should.equal("InvalidSnapshot.NotFound")
|
||||
cm.exception.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
cm.value.response["Error"]["Code"].should.equal("InvalidSnapshot.NotFound")
|
||||
cm.value.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
|
||||
# Error: Remove with invalid snapshot ID
|
||||
with assert_raises(ClientError) as cm:
|
||||
with pytest.raises(ClientError) as cm:
|
||||
ec2_client.modify_snapshot_attribute(
|
||||
SnapshotId="snapshot-abcd1234",
|
||||
Attribute="createVolumePermission",
|
||||
OperationType="remove",
|
||||
GroupNames=["all"],
|
||||
)
|
||||
cm.exception.response["Error"]["Code"].should.equal("InvalidSnapshot.NotFound")
|
||||
cm.exception.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
cm.value.response["Error"]["Code"].should.equal("InvalidSnapshot.NotFound")
|
||||
cm.value.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
|
||||
# Test adding user id
|
||||
ec2_client.modify_snapshot_attribute(
|
||||
|
|
@ -741,9 +741,9 @@ def test_create_volume_from_snapshot():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
snapshot = volume.create_snapshot("a test snapshot", 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 CreateSnapshot operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -789,9 +789,9 @@ def test_modify_attribute_blockDeviceMapping():
|
|||
instance.modify_attribute(
|
||||
"blockDeviceMapping", {"/dev/sda1": True}, 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 ModifyInstanceAttribute operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -810,9 +810,9 @@ def test_volume_tag_escaping():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
snapshot.add_tags({"key": "</closed>"}, 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 CreateTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
snaps = [snap for snap in conn.get_all_snapshots() if snap.id == snapshot.id]
|
||||
|
|
@ -880,12 +880,12 @@ def test_copy_snapshot():
|
|||
# Copy from non-existent source ID.
|
||||
with pytest.raises(ClientError) as cm:
|
||||
create_snapshot_error = ec2_client.create_snapshot(VolumeId="vol-abcd1234")
|
||||
cm.exception.response["Error"]["Code"].should.equal("InvalidVolume.NotFound")
|
||||
cm.exception.response["Error"]["Message"].should.equal(
|
||||
cm.value.response["Error"]["Code"].should.equal("InvalidVolume.NotFound")
|
||||
cm.value.response["Error"]["Message"].should.equal(
|
||||
"The volume 'vol-abcd1234' does not exist."
|
||||
)
|
||||
cm.exception.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
cm.value.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
|
||||
# Copy from non-existent source region.
|
||||
with pytest.raises(ClientError) as cm:
|
||||
|
|
@ -893,10 +893,10 @@ def test_copy_snapshot():
|
|||
SourceSnapshotId=create_snapshot_response["SnapshotId"],
|
||||
SourceRegion="eu-west-2",
|
||||
)
|
||||
cm.exception.response["Error"]["Code"].should.equal("InvalidSnapshot.NotFound")
|
||||
cm.exception.response["Error"]["Message"].should.be.none
|
||||
cm.exception.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
cm.value.response["Error"]["Code"].should.equal("InvalidSnapshot.NotFound")
|
||||
cm.value.response["Error"]["Message"].should.be.none
|
||||
cm.value.response["ResponseMetadata"]["RequestId"].should_not.be.none
|
||||
cm.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 boto3
|
||||
|
|
@ -22,9 +22,9 @@ def test_elastic_network_interfaces():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
eni = conn.create_network_interface(subnet.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 CreateNetworkInterface operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -39,9 +39,9 @@ def test_elastic_network_interfaces():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.delete_network_interface(eni.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 DeleteNetworkInterface operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -52,9 +52,9 @@ def test_elastic_network_interfaces():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_network_interface(eni.id)
|
||||
cm.exception.error_code.should.equal("InvalidNetworkInterfaceID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.error_code.should.equal("InvalidNetworkInterfaceID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -63,9 +63,9 @@ def test_elastic_network_interfaces_subnet_validation():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_network_interface("subnet-abcd1234")
|
||||
cm.exception.error_code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.error_code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -136,9 +136,9 @@ def test_elastic_network_interfaces_modify_attribute():
|
|||
conn.modify_network_interface_attribute(
|
||||
eni.id, "groupset", [security_group2.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 ModifyNetworkInterface operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -229,9 +229,9 @@ def test_elastic_network_interfaces_get_by_tag_name():
|
|||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
eni1.create_tags(Tags=[{"Key": "Name", "Value": "eni1"}], DryRun=True)
|
||||
ex.exception.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the CreateTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -44,9 +44,9 @@ def test_create_flow_logs_s3():
|
|||
LogDestination="arn:aws:s3:::" + bucket.name,
|
||||
DryRun=True,
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the CreateFlowLogs operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -96,9 +96,9 @@ def test_create_flow_logs_cloud_watch():
|
|||
DeliverLogsPermissionArn="arn:aws:iam::" + ACCOUNT_ID + ":role/test-role",
|
||||
DryRun=True,
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the CreateFlowLogs operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -244,17 +244,17 @@ def test_delete_flow_logs_non_existing():
|
|||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.delete_flow_logs(FlowLogIds=["fl-1a2b3c4d"])
|
||||
ex.exception.response["Error"]["Code"].should.equal("InvalidFlowLogId.NotFound")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidFlowLogId.NotFound")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"These flow log ids in the input list are not found: [TotalCount: 1] fl-1a2b3c4d"
|
||||
)
|
||||
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.delete_flow_logs(FlowLogIds=["fl-1a2b3c4d", "fl-2b3c4d5e"])
|
||||
ex.exception.response["Error"]["Code"].should.equal("InvalidFlowLogId.NotFound")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidFlowLogId.NotFound")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"These flow log ids in the input list are not found: [TotalCount: 2] fl-1a2b3c4d fl-2b3c4d5e"
|
||||
)
|
||||
|
||||
|
|
@ -312,9 +312,9 @@ def test_create_flow_logs_invalid_parameters():
|
|||
LogDestination="arn:aws:s3:::" + bucket.name,
|
||||
MaxAggregationInterval=10,
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Invalid Flow Log Max Aggregation Interval"
|
||||
)
|
||||
|
||||
|
|
@ -325,9 +325,9 @@ def test_create_flow_logs_invalid_parameters():
|
|||
TrafficType="ALL",
|
||||
LogDestinationType="s3",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"LogDestination can't be empty if LogGroupName is not provided."
|
||||
)
|
||||
|
||||
|
|
@ -339,9 +339,9 @@ def test_create_flow_logs_invalid_parameters():
|
|||
LogDestinationType="s3",
|
||||
LogGroupName="test",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"LogDestination type must be cloud-watch-logs if LogGroupName is provided."
|
||||
)
|
||||
|
||||
|
|
@ -352,9 +352,9 @@ def test_create_flow_logs_invalid_parameters():
|
|||
TrafficType="ALL",
|
||||
LogGroupName="test",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidParameter")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"DeliverLogsPermissionArn can't be empty if LogDestinationType is cloud-watch-logs."
|
||||
)
|
||||
|
||||
|
|
@ -375,9 +375,9 @@ def test_create_flow_logs_invalid_parameters():
|
|||
LogDestinationType="s3",
|
||||
LogDestination="arn:aws:s3:::" + bucket.name,
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("FlowLogAlreadyExists")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("FlowLogAlreadyExists")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Error. There is an existing Flow Log with the same configuration and log destination."
|
||||
)
|
||||
|
||||
|
|
@ -398,9 +398,9 @@ def test_create_flow_logs_invalid_parameters():
|
|||
LogGroupName="test-group",
|
||||
DeliverLogsPermissionArn="arn:aws:iam::" + ACCOUNT_ID + ":role/test-role",
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("FlowLogAlreadyExists")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("FlowLogAlreadyExists")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"Error. There is an existing Flow Log with the same configuration and log destination."
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -26,9 +26,9 @@ def test_console_output_without_instance():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_console_output("i-1234abcd")
|
||||
cm.exception.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
|
|||
|
|
@ -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
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
import pytest
|
||||
|
|
@ -53,9 +53,9 @@ def test_instance_launch_and_terminate():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
reservation = conn.run_instances("ami-1234abcd", 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 RunInstance operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -88,9 +88,9 @@ def test_instance_launch_and_terminate():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.terminate_instances([instance.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 TerminateInstance operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -215,14 +215,14 @@ def test_instance_detach_volume_wrong_path():
|
|||
)
|
||||
instance = result[0]
|
||||
for volume in instance.volumes.all():
|
||||
with assert_raises(ClientError) as ex:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
instance.detach_volume(VolumeId=volume.volume_id, Device="/dev/sdf")
|
||||
|
||||
ex.exception.response["Error"]["Code"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal(
|
||||
"InvalidAttachment.NotFound"
|
||||
)
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"The volume {0} is not attached to instance {1} as device {2}".format(
|
||||
volume.volume_id, instance.instance_id, "/dev/sdf"
|
||||
)
|
||||
|
|
@ -291,9 +291,9 @@ def test_get_instances_by_id():
|
|||
# Call get_all_instances with a bad id should raise an error
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_instances(instance_ids=[instance1.id, "i-1234abcd"])
|
||||
cm.exception.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
@ -744,9 +744,9 @@ def test_instance_start_and_stop():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
stopped_instances = conn.stop_instances(instance_ids, 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 StopInstance operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -757,9 +757,9 @@ def test_instance_start_and_stop():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
started_instances = conn.start_instances([instances[0].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 StartInstance operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -775,9 +775,9 @@ def test_instance_reboot():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
instance.reboot(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 RebootInstance operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -793,9 +793,9 @@ def test_instance_attribute_instance_type():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
instance.modify_attribute("instanceType", "m1.small", 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 ModifyInstanceType operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -821,9 +821,9 @@ def test_modify_instance_attribute_security_groups():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
instance.modify_attribute("groupSet", [sg_id, sg_id2], 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 ModifyInstanceSecurityGroups operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -844,9 +844,9 @@ def test_instance_attribute_user_data():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
instance.modify_attribute("userData", "this is my user data", 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 ModifyUserData operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -874,9 +874,9 @@ def test_instance_attribute_source_dest_check():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
instance.modify_attribute("sourceDestCheck", False, 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 ModifySourceDestCheck operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -920,9 +920,9 @@ def test_run_instance_with_security_group_name():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
group = conn.create_security_group("group1", "some description", 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 CreateSecurityGroup operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -1197,9 +1197,9 @@ def test_instance_with_nic_attach_detach():
|
|||
# Attach
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.attach_network_interface(eni.id, instance.id, device_index=1, 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 AttachNetworkInterface operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -1224,9 +1224,9 @@ def test_instance_with_nic_attach_detach():
|
|||
# Detach
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.detach_network_interface(instance_eni.attachment.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 DetachNetworkInterface operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -1243,9 +1243,9 @@ def test_instance_with_nic_attach_detach():
|
|||
# Detach with invalid attachment ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.detach_network_interface("eni-attach-1234abcd")
|
||||
cm.exception.code.should.equal("InvalidAttachmentID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidAttachmentID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -1306,12 +1306,12 @@ def test_run_instance_with_block_device_mappings_missing_ebs():
|
|||
"InstanceType": "t1.micro",
|
||||
"BlockDeviceMappings": [{"DeviceName": "/dev/sda2"}],
|
||||
}
|
||||
with assert_raises(ClientError) as ex:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
ec2_client.run_instances(**kwargs)
|
||||
|
||||
ex.exception.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"The request must contain the parameter ebs"
|
||||
)
|
||||
|
||||
|
|
@ -1330,12 +1330,12 @@ def test_run_instance_with_block_device_mappings_missing_size():
|
|||
{"DeviceName": "/dev/sda2", "Ebs": {"VolumeType": "standard"}}
|
||||
],
|
||||
}
|
||||
with assert_raises(ClientError) as ex:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
ec2_client.run_instances(**kwargs)
|
||||
|
||||
ex.exception.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"The request must contain the parameter size or snapshotId"
|
||||
)
|
||||
|
||||
|
|
@ -1411,9 +1411,9 @@ def test_describe_instance_status_with_instance_filter_deprecated():
|
|||
# Call get_all_instance_status with a bad id should raise an error
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_instance_status(instance_ids=[instance.id, "i-1234abcd"])
|
||||
cm.exception.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidInstanceID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
@ -1540,9 +1540,9 @@ def test_get_instance_by_security_group():
|
|||
conn.modify_instance_attribute(
|
||||
instance.id, "groupSet", [security_group.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 ModifyInstanceSecurityGroups operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -1664,9 +1664,9 @@ def test_describe_instance_attribute():
|
|||
client.describe_instance_attribute(
|
||||
InstanceId=instance_id, Attribute=invalid_instance_attribute
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("InvalidParameterValue")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Code"].should.equal("InvalidParameterValue")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
message = "Value ({invalid_instance_attribute}) for parameter attribute is invalid. Unknown attribute.".format(
|
||||
invalid_instance_attribute=invalid_instance_attribute
|
||||
)
|
||||
ex.exception.response["Error"]["Message"].should.equal(message)
|
||||
ex.value.response["Error"]["Message"].should.equal(message)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -57,9 +57,9 @@ def test_key_pairs_invalid_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_key_pairs("foo")
|
||||
cm.exception.code.should.equal("InvalidKeyPair.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidKeyPair.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -68,9 +68,9 @@ def test_key_pairs_create():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.create_key_pair("foo", 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 CreateKeyPair operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -111,9 +111,9 @@ def test_key_pairs_create_exist():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_key_pair("foo")
|
||||
cm.exception.code.should.equal("InvalidKeyPair.Duplicate")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidKeyPair.Duplicate")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -131,9 +131,9 @@ def test_key_pairs_delete_exist():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
r = conn.delete_key_pair("foo", 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 DeleteKeyPair operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -148,9 +148,9 @@ def test_key_pairs_import():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.import_key_pair("foo", RSA_PUBLIC_KEY_OPENSSH, 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 ImportKeyPair operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -177,9 +177,9 @@ def test_key_pairs_import_exist():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_key_pair("foo")
|
||||
cm.exception.code.should.equal("InvalidKeyPair.Duplicate")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidKeyPair.Duplicate")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -188,21 +188,21 @@ def test_key_pairs_invalid():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.import_key_pair("foo", b"")
|
||||
ex.exception.error_code.should.equal("InvalidKeyPair.Format")
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal("Key is not in valid OpenSSH public key format")
|
||||
ex.value.error_code.should.equal("InvalidKeyPair.Format")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal("Key is not in valid OpenSSH public key format")
|
||||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.import_key_pair("foo", b"garbage")
|
||||
ex.exception.error_code.should.equal("InvalidKeyPair.Format")
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal("Key is not in valid OpenSSH public key format")
|
||||
ex.value.error_code.should.equal("InvalidKeyPair.Format")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal("Key is not in valid OpenSSH public key format")
|
||||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.import_key_pair("foo", DSA_PUBLIC_KEY_OPENSSH)
|
||||
ex.exception.error_code.should.equal("InvalidKeyPair.Format")
|
||||
ex.exception.status.should.equal(400)
|
||||
ex.exception.message.should.equal("Key is not in valid OpenSSH public key format")
|
||||
ex.value.error_code.should.equal("InvalidKeyPair.Format")
|
||||
ex.value.status.should.equal(400)
|
||||
ex.value.message.should.equal("Key is not in valid OpenSSH public key format")
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ def test_launch_template_create():
|
|||
},
|
||||
)
|
||||
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidLaunchTemplateName.AlreadyExistsException) when calling the CreateLaunchTemplate operation: Launch template name already in use."
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ def test_duplicate_network_acl_entry():
|
|||
RuleAction="deny",
|
||||
RuleNumber=rule_number,
|
||||
)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (NetworkAclEntryAlreadyExists) when calling the CreateNetworkAclEntry "
|
||||
"operation: The network acl entry identified by {} already exists.".format(
|
||||
rule_number
|
||||
|
|
@ -297,10 +297,10 @@ def test_describe_network_acls():
|
|||
resp2 = conn.describe_network_acls()["NetworkAcls"]
|
||||
resp2.should.have.length_of(3)
|
||||
|
||||
with assert_raises(ClientError) as ex:
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.describe_network_acls(NetworkAclIds=["1"])
|
||||
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidRouteTableID.NotFound) when calling the "
|
||||
"DescribeNetworkAcls operation: The routeTable ID '1' does not exist"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -62,9 +62,9 @@ def test_route_tables_additional():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_vpc(vpc.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
|
||||
|
||||
conn.delete_route_table(route_table.id)
|
||||
|
||||
|
|
@ -73,9 +73,9 @@ def test_route_tables_additional():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_route_table("rtb-1234abcd")
|
||||
cm.exception.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -198,9 +198,9 @@ def test_route_table_associations():
|
|||
# Error: Attempt delete associated route table.
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_route_table(route_table.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
|
||||
|
||||
# Disassociate
|
||||
conn.disassociate_route_table(association_id)
|
||||
|
|
@ -212,23 +212,23 @@ def test_route_table_associations():
|
|||
# Error: Disassociate with invalid association ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.disassociate_route_table(association_id)
|
||||
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
|
||||
|
||||
# Error: Associate with invalid subnet ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_route_table(route_table.id, "subnet-1234abcd")
|
||||
cm.exception.code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Error: Associate with invalid route table ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.associate_route_table("rtb-1234abcd", subnet.id)
|
||||
cm.exception.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@requires_boto_gte("2.16.0")
|
||||
|
|
@ -296,16 +296,16 @@ def test_route_table_replace_route_table_association():
|
|||
conn.replace_route_table_association_with_assoc(
|
||||
"rtbassoc-1234abcd", route_table1.id
|
||||
)
|
||||
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
|
||||
|
||||
# Error: Replace association with invalid route table ID
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.replace_route_table_association_with_assoc(association_id2, "rtb-1234abcd")
|
||||
cm.exception.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -390,9 +390,9 @@ def test_routes_additional():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_route(main_route_table.id, ROUTE_CIDR)
|
||||
cm.exception.code.should.equal("InvalidRoute.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidRoute.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -443,9 +443,9 @@ def test_routes_replace():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.replace_route("rtb-1234abcd", ROUTE_CIDR, gateway_id=igw.id)
|
||||
cm.exception.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidRouteTableID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@requires_boto_gte("2.19.0")
|
||||
|
|
@ -574,7 +574,7 @@ def test_create_route_with_invalid_destination_cidr_block_parameter():
|
|||
route = route_table.create_route(
|
||||
DestinationCidrBlock=destination_cidr_block, GatewayId=internet_gateway.id
|
||||
)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidParameterValue) when calling the CreateRoute "
|
||||
"operation: Value ({}) for parameter destinationCidrBlock is invalid. This is not a valid CIDR block.".format(
|
||||
destination_cidr_block
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||
import copy
|
||||
import json
|
||||
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
# Ensure 'pytest.raises' context manager support for Python 2.6
|
||||
import pytest
|
||||
|
||||
import boto3
|
||||
|
|
@ -23,9 +23,9 @@ def test_create_and_describe_security_group():
|
|||
security_group = conn.create_security_group(
|
||||
"test security group", "this is a test security group", 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 CreateSecurityGroup operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -41,9 +41,9 @@ def test_create_and_describe_security_group():
|
|||
conn.create_security_group(
|
||||
"test security group", "this is a test security group"
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidGroup.Duplicate")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidGroup.Duplicate")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
all_groups = conn.get_all_security_groups()
|
||||
# The default group gets created automatically
|
||||
|
|
@ -58,9 +58,9 @@ def test_create_security_group_without_description_raises_error():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_security_group("test security group", "")
|
||||
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
|
||||
|
|
@ -90,9 +90,9 @@ def test_create_and_describe_vpc_security_group():
|
|||
conn.create_security_group(
|
||||
"test security group", "this is a test security group", vpc_id
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidGroup.Duplicate")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidGroup.Duplicate")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
all_groups = conn.get_all_security_groups(filters={"vpc_id": [vpc_id]})
|
||||
|
||||
|
|
@ -147,16 +147,16 @@ def test_deleting_security_groups():
|
|||
# Deleting a group that doesn't exist should throw an error
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_security_group("foobar")
|
||||
cm.exception.code.should.equal("InvalidGroup.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidGroup.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Delete by name
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.delete_security_group("test2", 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 DeleteSecurityGroup operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -191,9 +191,9 @@ def test_authorize_ip_range_and_revoke():
|
|||
cidr_ip="123.123.123.123/32",
|
||||
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 GrantSecurityGroupIngress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -214,9 +214,9 @@ def test_authorize_ip_range_and_revoke():
|
|||
to_port="2222",
|
||||
cidr_ip="123.123.123.122/32",
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidPermission.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidPermission.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Actually revoke
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
|
|
@ -227,9 +227,9 @@ def test_authorize_ip_range_and_revoke():
|
|||
cidr_ip="123.123.123.123/32",
|
||||
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 RevokeSecurityGroupIngress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -254,9 +254,9 @@ def test_authorize_ip_range_and_revoke():
|
|||
cidr_ip="123.123.123.123/32",
|
||||
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 GrantSecurityGroupEgress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -293,9 +293,9 @@ def test_authorize_ip_range_and_revoke():
|
|||
cidr_ip="123.123.123.123/32",
|
||||
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 RevokeSecurityGroupEgress operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -338,9 +338,9 @@ def test_authorize_other_group_and_revoke():
|
|||
security_group.revoke(
|
||||
ip_protocol="tcp", from_port="22", to_port="2222", src_group=wrong_group
|
||||
)
|
||||
cm.exception.code.should.equal("InvalidPermission.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidPermission.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
# Actually revoke
|
||||
security_group.revoke(
|
||||
|
|
@ -441,9 +441,9 @@ def test_get_all_security_groups():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_security_groups(groupnames=["does_not_exist"])
|
||||
cm.exception.code.should.equal("InvalidGroup.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidGroup.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
resp.should.have.length_of(1)
|
||||
resp[0].id.should.equal(sg1.id)
|
||||
|
|
@ -472,9 +472,9 @@ def test_authorize_bad_cidr_throws_invalid_parameter_value():
|
|||
security_group.authorize(
|
||||
ip_protocol="tcp", from_port="22", to_port="2222", cidr_ip="123.123.123.123"
|
||||
)
|
||||
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
|
||||
|
|
@ -486,9 +486,9 @@ def test_security_group_tagging():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
sg.add_tag("Test", "Tag", 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 CreateTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -539,7 +539,7 @@ def test_sec_group_rule_limit():
|
|||
ip_protocol="-1",
|
||||
cidr_ip=["{0}.0.0.0/0".format(i) for i in range(110)],
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
|
||||
sg.rules.should.be.empty
|
||||
# authorize a rule targeting a different sec group (because this count too)
|
||||
|
|
@ -559,13 +559,13 @@ def test_sec_group_rule_limit():
|
|||
ec2_conn.authorize_security_group(
|
||||
group_id=sg.id, ip_protocol="-1", cidr_ip=["100.0.0.0/0"]
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
# verify that we cannot authorize past the limit for a different sec group
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
ec2_conn.authorize_security_group(
|
||||
group_id=sg.id, ip_protocol="-1", src_security_group_group_id=other_sg.id
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
|
||||
# EGRESS
|
||||
# authorize a rule targeting a different sec group (because this count too)
|
||||
|
|
@ -584,13 +584,13 @@ def test_sec_group_rule_limit():
|
|||
ec2_conn.authorize_security_group_egress(
|
||||
group_id=sg.id, ip_protocol="-1", cidr_ip="101.0.0.0/0"
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
# verify that we cannot authorize past the limit for a different sec group
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
ec2_conn.authorize_security_group_egress(
|
||||
group_id=sg.id, ip_protocol="-1", src_group_id=other_sg.id
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -610,7 +610,7 @@ def test_sec_group_rule_limit_vpc():
|
|||
ip_protocol="-1",
|
||||
cidr_ip=["{0}.0.0.0/0".format(i) for i in range(110)],
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
|
||||
sg.rules.should.be.empty
|
||||
# authorize a rule targeting a different sec group (because this count too)
|
||||
|
|
@ -630,13 +630,13 @@ def test_sec_group_rule_limit_vpc():
|
|||
ec2_conn.authorize_security_group(
|
||||
group_id=sg.id, ip_protocol="-1", cidr_ip=["100.0.0.0/0"]
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
# verify that we cannot authorize past the limit for a different sec group
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
ec2_conn.authorize_security_group(
|
||||
group_id=sg.id, ip_protocol="-1", src_security_group_group_id=other_sg.id
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
|
||||
# EGRESS
|
||||
# authorize a rule targeting a different sec group (because this count too)
|
||||
|
|
@ -655,13 +655,13 @@ def test_sec_group_rule_limit_vpc():
|
|||
ec2_conn.authorize_security_group_egress(
|
||||
group_id=sg.id, ip_protocol="-1", cidr_ip="50.0.0.0/0"
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
# verify that we cannot authorize past the limit for a different sec group
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
ec2_conn.authorize_security_group_egress(
|
||||
group_id=sg.id, ip_protocol="-1", src_group_id=other_sg.id
|
||||
)
|
||||
cm.exception.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
cm.value.error_code.should.equal("RulesPerSecurityGroupLimitExceeded")
|
||||
|
||||
|
||||
"""
|
||||
|
|
@ -766,9 +766,9 @@ def test_security_group_tagging_boto3():
|
|||
Tags=[{"Key": "Test", "Value": "Tag"}],
|
||||
DryRun=True,
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the CreateTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -927,9 +927,9 @@ def test_get_all_security_groups_filter_with_same_vpc_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_security_groups(group_ids=["does_not_exist"])
|
||||
cm.exception.code.should.equal("InvalidGroup.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidGroup.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
|
|||
|
|
@ -54,9 +54,9 @@ def test_request_spot_instances():
|
|||
},
|
||||
DryRun=True,
|
||||
)
|
||||
ex.exception.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.exception.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("DryRunOperation")
|
||||
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"An error occurred (DryRunOperation) when calling the RequestSpotInstance operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -157,9 +157,9 @@ def test_cancel_spot_instance_request():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.cancel_spot_instance_requests([requests[0].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 CancelSpotInstance operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 boto3
|
||||
|
|
@ -31,9 +31,9 @@ def test_subnets():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_subnet(subnet.id)
|
||||
cm.exception.code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -42,9 +42,9 @@ def test_subnet_create_vpc_validation():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_subnet("vpc-abcd1234", "10.0.0.0/18")
|
||||
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
|
||||
|
|
@ -229,9 +229,9 @@ def test_subnet_get_by_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_subnets(subnet_ids=["subnet-does_not_exist"])
|
||||
cm.exception.code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidSubnetID.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -391,7 +391,7 @@ def test_create_subnet_with_invalid_availability_zone():
|
|||
CidrBlock="10.0.0.0/24",
|
||||
AvailabilityZone=subnet_availability_zone,
|
||||
)
|
||||
assert str(ex.exception).startswith(
|
||||
assert str(ex.value).startswith(
|
||||
"An error occurred (InvalidParameterValue) when calling the CreateSubnet "
|
||||
"operation: Value ({}) for parameter availabilityZone is invalid. Subnets can currently only be created in the following availability zones: ".format(
|
||||
subnet_availability_zone
|
||||
|
|
@ -410,7 +410,7 @@ def test_create_subnet_with_invalid_cidr_range():
|
|||
subnet_cidr_block = "10.1.0.0/20"
|
||||
with pytest.raises(ClientError) as ex:
|
||||
subnet = ec2.create_subnet(VpcId=vpc.id, CidrBlock=subnet_cidr_block)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidSubnet.Range) when calling the CreateSubnet "
|
||||
"operation: The CIDR '{}' is invalid.".format(subnet_cidr_block)
|
||||
)
|
||||
|
|
@ -445,7 +445,7 @@ def test_create_subnet_with_invalid_cidr_block_parameter():
|
|||
subnet_cidr_block = "1000.1.0.0/20"
|
||||
with pytest.raises(ClientError) as ex:
|
||||
subnet = ec2.create_subnet(VpcId=vpc.id, CidrBlock=subnet_cidr_block)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidParameterValue) when calling the CreateSubnet "
|
||||
"operation: Value ({}) for parameter cidrBlock is invalid. This is not a valid CIDR block.".format(
|
||||
subnet_cidr_block
|
||||
|
|
@ -505,7 +505,7 @@ def test_create_subnets_with_overlapping_cidr_blocks():
|
|||
with pytest.raises(ClientError) as ex:
|
||||
subnet1 = ec2.create_subnet(VpcId=vpc.id, CidrBlock=subnet_cidr_block)
|
||||
subnet2 = ec2.create_subnet(VpcId=vpc.id, CidrBlock=subnet_cidr_block)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidSubnet.Conflict) when calling the CreateSubnet "
|
||||
"operation: The CIDR '{}' conflicts with another subnet".format(
|
||||
subnet_cidr_block
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ def test_add_tag():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
instance.add_tag("a key", "some value", 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 CreateTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -53,9 +53,9 @@ def test_remove_tag():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
instance.remove_tag("a key", 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 DeleteTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -108,9 +108,9 @@ def test_create_tags():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as ex:
|
||||
conn.create_tags(instance.id, tag_dict, 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 CreateTags operation: Request would have succeeded, but DryRun flag is set"
|
||||
)
|
||||
|
||||
|
|
@ -133,16 +133,16 @@ def test_tag_limit_exceeded():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_tags(instance.id, tag_dict)
|
||||
cm.exception.code.should.equal("TagLimitExceeded")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("TagLimitExceeded")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
instance.add_tag("a key", "a value")
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_tags(instance.id, tag_dict)
|
||||
cm.exception.code.should.equal("TagLimitExceeded")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("TagLimitExceeded")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
tags = conn.get_all_tags()
|
||||
tag = tags[0]
|
||||
|
|
@ -159,9 +159,9 @@ def test_invalid_parameter_tag_null():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
instance.add_tag("a key", None)
|
||||
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
|
||||
|
|
@ -169,15 +169,15 @@ def test_invalid_id():
|
|||
conn = boto.connect_ec2("the_key", "the_secret")
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_tags("ami-blah", {"key": "tag"})
|
||||
cm.exception.code.should.equal("InvalidID")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidID")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.create_tags("blah-blah", {"key": "tag"})
|
||||
cm.exception.code.should.equal("InvalidID")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidID")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2_deprecated
|
||||
|
|
@ -451,8 +451,8 @@ def test_create_tag_empty_resource():
|
|||
# create tag with empty resource
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.create_tags(Resources=[], Tags=[{"Key": "Value"}])
|
||||
ex.exception.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"The request must contain the parameter resourceIdSet"
|
||||
)
|
||||
|
||||
|
|
@ -464,8 +464,8 @@ def test_delete_tag_empty_resource():
|
|||
# delete tag with empty resource
|
||||
with pytest.raises(ClientError) as ex:
|
||||
client.delete_tags(Resources=[], Tags=[{"Key": "Value"}])
|
||||
ex.exception.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.exception.response["Error"]["Message"].should.equal(
|
||||
ex.value.response["Error"]["Code"].should.equal("MissingParameter")
|
||||
ex.value.response["Error"]["Message"].should.equal(
|
||||
"The request must contain the parameter resourceIdSet"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
from moto.ec2.exceptions import EC2ClientError
|
||||
from botocore.exceptions import ClientError
|
||||
|
|
@ -50,9 +50,9 @@ def test_vpc_peering_connections_accept():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.reject_vpc_peering_connection(vpc_pcx.id)
|
||||
cm.exception.code.should.equal("InvalidStateTransition")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidStateTransition")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
all_vpc_pcxs = conn.get_all_vpc_peering_connections()
|
||||
all_vpc_pcxs.should.have.length_of(1)
|
||||
|
|
@ -70,9 +70,9 @@ def test_vpc_peering_connections_reject():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.accept_vpc_peering_connection(vpc_pcx.id)
|
||||
cm.exception.code.should.equal("InvalidStateTransition")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidStateTransition")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
all_vpc_pcxs = conn.get_all_vpc_peering_connections()
|
||||
all_vpc_pcxs.should.have.length_of(1)
|
||||
|
|
@ -94,9 +94,9 @@ def test_vpc_peering_connections_delete():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_vpc_peering_connection("pcx-1234abcd")
|
||||
cm.exception.code.should.equal("InvalidVpcPeeringConnectionId.NotFound")
|
||||
cm.exception.status.should.equal(400)
|
||||
cm.exception.request_id.should_not.be.none
|
||||
cm.value.code.should.equal("InvalidVpcPeeringConnectionId.NotFound")
|
||||
cm.value.status.should.equal(400)
|
||||
cm.value.request_id.should_not.be.none
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
@ -132,7 +132,7 @@ def test_vpc_peering_connections_cross_region_fail():
|
|||
ec2_usw1.create_vpc_peering_connection(
|
||||
VpcId=vpc_usw1.id, PeerVpcId=vpc_apn1.id, PeerRegion="ap-northeast-2"
|
||||
)
|
||||
cm.exception.response["Error"]["Code"].should.equal("InvalidVpcID.NotFound")
|
||||
cm.value.response["Error"]["Code"].should.equal("InvalidVpcID.NotFound")
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
@ -254,13 +254,13 @@ def test_vpc_peering_connections_cross_region_accept_wrong_region():
|
|||
ec2_usw1 = boto3.client("ec2", region_name="us-west-1")
|
||||
with pytest.raises(ClientError) as cm:
|
||||
ec2_usw1.accept_vpc_peering_connection(VpcPeeringConnectionId=vpc_pcx_usw1.id)
|
||||
cm.exception.response["Error"]["Code"].should.equal("OperationNotPermitted")
|
||||
cm.value.response["Error"]["Code"].should.equal("OperationNotPermitted")
|
||||
exp_msg = (
|
||||
"Incorrect region ({0}) specified for this request.VPC "
|
||||
"peering connection {1} must be "
|
||||
"accepted in region {2}".format("us-west-1", vpc_pcx_usw1.id, "ap-northeast-1")
|
||||
)
|
||||
cm.exception.response["Error"]["Message"].should.equal(exp_msg)
|
||||
cm.value.response["Error"]["Message"].should.equal(exp_msg)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
|
|
@ -279,10 +279,10 @@ def test_vpc_peering_connections_cross_region_reject_wrong_region():
|
|||
ec2_usw1 = boto3.client("ec2", region_name="us-west-1")
|
||||
with pytest.raises(ClientError) as cm:
|
||||
ec2_usw1.reject_vpc_peering_connection(VpcPeeringConnectionId=vpc_pcx_usw1.id)
|
||||
cm.exception.response["Error"]["Code"].should.equal("OperationNotPermitted")
|
||||
cm.value.response["Error"]["Code"].should.equal("OperationNotPermitted")
|
||||
exp_msg = (
|
||||
"Incorrect region ({0}) specified for this request.VPC "
|
||||
"peering connection {1} must be accepted or "
|
||||
"rejected in region {2}".format("us-west-1", vpc_pcx_usw1.id, "ap-northeast-1")
|
||||
)
|
||||
cm.exception.response["Error"]["Message"].should.equal(exp_msg)
|
||||
cm.value.response["Error"]["Message"].should.equal(exp_msg)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
from moto.ec2.exceptions import EC2ClientError
|
||||
from botocore.exceptions import ClientError
|
||||
|
|
@ -32,9 +32,9 @@ def test_vpcs():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.delete_vpc("vpc-1234abcd")
|
||||
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
|
||||
|
|
@ -115,9 +115,9 @@ def test_vpc_get_by_id():
|
|||
|
||||
with pytest.raises(EC2ResponseError) as cm:
|
||||
conn.get_all_vpcs(vpc_ids=["vpc-does_not_exist"])
|
||||
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
|
||||
|
|
@ -405,7 +405,7 @@ def test_associate_vpc_ipv4_cidr_block():
|
|||
response = ec2.meta.client.associate_vpc_cidr_block(
|
||||
VpcId=vpc.id, CidrBlock="10.10.50.0/22"
|
||||
)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (CidrLimitExceeded) when calling the AssociateVpcCidrBlock "
|
||||
"operation: This network '{}' has met its maximum number of allowed CIDRs: 5".format(
|
||||
vpc.id
|
||||
|
|
@ -450,7 +450,7 @@ def test_disassociate_vpc_ipv4_cidr_block():
|
|||
response = ec2.meta.client.disassociate_vpc_cidr_block(
|
||||
AssociationId="vpc-cidr-assoc-BORING123"
|
||||
)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidVpcCidrBlockAssociationIdError.NotFound) when calling the "
|
||||
"DisassociateVpcCidrBlock operation: The vpc CIDR block association ID "
|
||||
"'vpc-cidr-assoc-BORING123' does not exist"
|
||||
|
|
@ -472,7 +472,7 @@ def test_disassociate_vpc_ipv4_cidr_block():
|
|||
response = ec2.meta.client.disassociate_vpc_cidr_block(
|
||||
AssociationId=vpc_base_cidr_assoc_id
|
||||
)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (OperationNotPermitted) when calling the DisassociateVpcCidrBlock operation: "
|
||||
"The vpc CIDR block with association ID {} may not be disassociated. It is the primary "
|
||||
"IPv4 CIDR block of the VPC".format(vpc_base_cidr_assoc_id)
|
||||
|
|
@ -552,7 +552,7 @@ def test_vpc_associate_ipv6_cidr_block():
|
|||
response = ec2.meta.client.associate_vpc_cidr_block(
|
||||
VpcId=vpc.id, AmazonProvidedIpv6CidrBlock=True
|
||||
)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (CidrLimitExceeded) when calling the AssociateVpcCidrBlock "
|
||||
"operation: This network '{}' has met its maximum number of allowed CIDRs: 1".format(
|
||||
vpc.id
|
||||
|
|
@ -658,7 +658,7 @@ def test_create_vpc_with_invalid_cidr_block_parameter():
|
|||
vpc_cidr_block = "1000.1.0.0/20"
|
||||
with pytest.raises(ClientError) as ex:
|
||||
vpc = ec2.create_vpc(CidrBlock=vpc_cidr_block)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidParameterValue) when calling the CreateVpc "
|
||||
"operation: Value ({}) for parameter cidrBlock is invalid. This is not a valid CIDR block.".format(
|
||||
vpc_cidr_block
|
||||
|
|
@ -673,7 +673,7 @@ def test_create_vpc_with_invalid_cidr_range():
|
|||
vpc_cidr_block = "10.1.0.0/29"
|
||||
with pytest.raises(ClientError) as ex:
|
||||
vpc = ec2.create_vpc(CidrBlock=vpc_cidr_block)
|
||||
str(ex.exception).should.equal(
|
||||
str(ex.value).should.equal(
|
||||
"An error occurred (InvalidVpc.Range) when calling the CreateVpc "
|
||||
"operation: The CIDR '{}' is invalid.".format(vpc_cidr_block)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue