2013-02-22 04:13:01 +00:00
|
|
|
import boto
|
2013-03-06 03:33:41 +00:00
|
|
|
from boto.exception import EC2ResponseError
|
2013-08-03 21:21:25 +00:00
|
|
|
import sure # noqa
|
2014-08-25 17:54:47 +00:00
|
|
|
from nose.tools import assert_raises
|
2013-02-22 04:13:01 +00:00
|
|
|
|
|
|
|
from moto import mock_ec2
|
|
|
|
|
|
|
|
|
|
|
|
@mock_ec2
|
|
|
|
def test_vpcs():
|
2013-03-06 03:33:41 +00:00
|
|
|
conn = boto.connect_vpc('the_key', 'the_secret')
|
|
|
|
vpc = conn.create_vpc("10.0.0.0/16")
|
|
|
|
vpc.cidr_block.should.equal('10.0.0.0/16')
|
|
|
|
|
|
|
|
all_vpcs = conn.get_all_vpcs()
|
|
|
|
all_vpcs.should.have.length_of(1)
|
|
|
|
|
|
|
|
vpc.delete()
|
|
|
|
|
|
|
|
all_vpcs = conn.get_all_vpcs()
|
|
|
|
all_vpcs.should.have.length_of(0)
|
|
|
|
|
2014-08-25 17:54:47 +00:00
|
|
|
with assert_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
|
2014-05-11 23:00:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
@mock_ec2
|
|
|
|
def test_vpc_tagging():
|
|
|
|
conn = boto.connect_vpc()
|
|
|
|
vpc = conn.create_vpc("10.0.0.0/16")
|
|
|
|
|
|
|
|
vpc.add_tag("a key", "some value")
|
|
|
|
|
|
|
|
tag = conn.get_all_tags()[0]
|
|
|
|
tag.name.should.equal("a key")
|
|
|
|
tag.value.should.equal("some value")
|
|
|
|
|
|
|
|
# Refresh the vpc
|
|
|
|
vpc = conn.get_all_vpcs()[0]
|
|
|
|
vpc.tags.should.have.length_of(1)
|
|
|
|
vpc.tags["a key"].should.equal("some value")
|