Fix conflict with subnet/network ACL association during subnet creation.
This commit is contained in:
commit
2a6c4c89bf
54 changed files with 616 additions and 303 deletions
|
|
@ -1,9 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
# Ensure 'assert_raises' context manager support for Python 2.6
|
||||
import tests.backport_assert_raises
|
||||
import tests.backport_assert_raises # noqa
|
||||
from nose.tools import assert_raises
|
||||
|
||||
import boto
|
||||
import boto.ec2
|
||||
from boto.exception import EC2ResponseError
|
||||
|
||||
import sure # noqa
|
||||
|
|
@ -55,7 +56,7 @@ def test_ami_create_and_delete():
|
|||
@requires_boto_gte("2.14.0")
|
||||
@mock_ec2
|
||||
def test_ami_copy():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-west-1")
|
||||
reservation = conn.run_instances('ami-1234abcd')
|
||||
instance = reservation.instances[0]
|
||||
|
||||
|
|
@ -183,6 +184,7 @@ def test_ami_filters():
|
|||
amis_by_name = conn.get_all_images(filters={'name': imageA.name})
|
||||
set([ami.id for ami in amis_by_name]).should.equal(set([imageA.id]))
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_ami_filtering_via_tag():
|
||||
conn = boto.connect_vpc('the_key', 'the_secret')
|
||||
|
|
@ -309,4 +311,3 @@ def test_ami_attribute():
|
|||
attribute='launchPermission',
|
||||
operation='remove',
|
||||
user_ids=['user']).should.throw(NotImplementedError)
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ def test_modify_attribute_blockDeviceMapping():
|
|||
|
||||
[0] https://github.com/spulec/moto/issues/160
|
||||
"""
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
|
||||
reservation = conn.run_instances('ami-1234abcd')
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import tests.backport_assert_raises
|
|||
from nose.tools import assert_raises
|
||||
|
||||
import boto
|
||||
import boto.cloudformation
|
||||
import boto.ec2
|
||||
from boto.exception import EC2ResponseError
|
||||
import sure # noqa
|
||||
|
||||
|
|
@ -151,12 +153,12 @@ def test_elastic_network_interfaces_filtering():
|
|||
def test_elastic_network_interfaces_cloudformation():
|
||||
template = vpc_eni.template
|
||||
template_json = json.dumps(template)
|
||||
conn = boto.connect_cloudformation()
|
||||
conn = boto.cloudformation.connect_to_region("us-west-1")
|
||||
conn.create_stack(
|
||||
"test_stack",
|
||||
template_body=template_json,
|
||||
)
|
||||
ec2_conn = boto.connect_ec2()
|
||||
ec2_conn = boto.ec2.connect_to_region("us-west-1")
|
||||
eni = ec2_conn.get_all_network_interfaces()[0]
|
||||
|
||||
stack = conn.describe_stacks()[0]
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ def test_request_spot_instances_fulfilled():
|
|||
"""
|
||||
Test that moto correctly fullfills a spot instance request
|
||||
"""
|
||||
conn = boto.connect_ec2()
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
|
||||
request = conn.request_spot_instances(
|
||||
price=0.5, image_id='ami-abcd1234',
|
||||
|
|
@ -184,7 +184,7 @@ def test_get_all_spot_instance_requests_filtering():
|
|||
|
||||
@mock_ec2
|
||||
def test_request_spot_instances_setting_instance_id():
|
||||
conn = boto.connect_ec2()
|
||||
conn = boto.ec2.connect_to_region("us-east-1")
|
||||
request = conn.request_spot_instances(
|
||||
price=0.5, image_id='ami-abcd1234')
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import itertools
|
|||
|
||||
import boto
|
||||
from boto.exception import EC2ResponseError
|
||||
from boto.ec2.instance import Reservation
|
||||
import sure # noqa
|
||||
|
||||
from moto import mock_ec2
|
||||
|
|
@ -253,3 +254,79 @@ def test_get_all_tags_value_filter():
|
|||
|
||||
tags = conn.get_all_tags(filters={'value': '*value\*\?'})
|
||||
tags.should.have.length_of(1)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_retrieved_instances_must_contain_their_tags():
|
||||
tag_key = 'Tag name'
|
||||
tag_value = 'Tag value'
|
||||
tags_to_be_set = {tag_key: tag_value}
|
||||
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
reservation = conn.run_instances('ami-1234abcd')
|
||||
reservation.should.be.a(Reservation)
|
||||
reservation.instances.should.have.length_of(1)
|
||||
instance = reservation.instances[0]
|
||||
|
||||
reservations = conn.get_all_instances()
|
||||
reservations.should.have.length_of(1)
|
||||
reservations[0].id.should.equal(reservation.id)
|
||||
instances = reservations[0].instances
|
||||
instances.should.have.length_of(1)
|
||||
instances[0].id.should.equal(instance.id)
|
||||
|
||||
conn.create_tags([instance.id], tags_to_be_set)
|
||||
reservations = conn.get_all_instances()
|
||||
instance = reservations[0].instances[0]
|
||||
retrieved_tags = instance.tags
|
||||
|
||||
#Cleanup of instance
|
||||
conn.terminate_instances([instances[0].id])
|
||||
|
||||
#Check whether tag is present with correct value
|
||||
retrieved_tags[tag_key].should.equal(tag_value)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_retrieved_volumes_must_contain_their_tags():
|
||||
tag_key = 'Tag name'
|
||||
tag_value = 'Tag value'
|
||||
tags_to_be_set = {tag_key: tag_value}
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
volume = conn.create_volume(80, "us-east-1a")
|
||||
|
||||
all_volumes = conn.get_all_volumes()
|
||||
volume = all_volumes[0]
|
||||
conn.create_tags([volume.id], tags_to_be_set)
|
||||
|
||||
#Fetch the volume again
|
||||
all_volumes = conn.get_all_volumes()
|
||||
volume = all_volumes[0]
|
||||
retrieved_tags = volume.tags
|
||||
|
||||
volume.delete()
|
||||
|
||||
#Check whether tag is present with correct value
|
||||
retrieved_tags[tag_key].should.equal(tag_value)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_retrieved_snapshots_must_contain_their_tags():
|
||||
tag_key = 'Tag name'
|
||||
tag_value = 'Tag value'
|
||||
tags_to_be_set = {tag_key: tag_value}
|
||||
conn = boto.connect_ec2(aws_access_key_id='the_key', aws_secret_access_key='the_secret')
|
||||
volume = conn.create_volume(80, "eu-west-1a")
|
||||
snapshot = conn.create_snapshot(volume.id)
|
||||
conn.create_tags([snapshot.id], tags_to_be_set)
|
||||
|
||||
#Fetch the snapshot again
|
||||
all_snapshots = conn.get_all_snapshots()
|
||||
snapshot = all_snapshots[0]
|
||||
retrieved_tags = snapshot.tags
|
||||
|
||||
conn.delete_snapshot(snapshot.id)
|
||||
volume.delete()
|
||||
|
||||
#Check whether tag is present with correct value
|
||||
retrieved_tags[tag_key].should.equal(tag_value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue