Add tagging to all applicable EC2 objects. Closes #66.
This commit is contained in:
parent
06481ebe7e
commit
955b4c6c4a
9 changed files with 159 additions and 22 deletions
|
|
@ -22,6 +22,26 @@ def test_ami_create_and_delete():
|
|||
success = conn.deregister_image.when.called_with(image).should.throw(EC2ResponseError)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_ami_tagging():
|
||||
conn = boto.connect_vpc('the_key', 'the_secret')
|
||||
reservation = conn.run_instances('ami-1234abcd')
|
||||
instance = reservation.instances[0]
|
||||
conn.create_image(instance.id, "test-ami", "this is a test ami")
|
||||
image = conn.get_all_images()[0]
|
||||
|
||||
image.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 DHCP options
|
||||
image = conn.get_all_images()[0]
|
||||
image.tags.should.have.length_of(1)
|
||||
image.tags["a key"].should.equal("some value")
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_ami_create_from_missing_instance():
|
||||
conn = boto.connect_ec2('the_key', 'the_secret')
|
||||
|
|
|
|||
|
|
@ -114,5 +114,22 @@ def test_delete_dhcp_options():
|
|||
def test_delete_dhcp_options_invalid_id():
|
||||
conn = boto.connect_vpc('the_key', 'the_secret')
|
||||
|
||||
dhcp_option = conn.create_dhcp_options()
|
||||
conn.create_dhcp_options()
|
||||
conn.delete_dhcp_options.when.called_with("1").should.throw(EC2ResponseError)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_dhcp_tagging():
|
||||
conn = boto.connect_vpc('the_key', 'the_secret')
|
||||
dhcp_option = conn.create_dhcp_options()
|
||||
|
||||
dhcp_option.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 DHCP options
|
||||
dhcp_option = conn.get_all_dhcp_options()[0]
|
||||
dhcp_option.tags.should.have.length_of(1)
|
||||
dhcp_option.tags["a key"].should.equal("some value")
|
||||
|
|
|
|||
|
|
@ -21,3 +21,21 @@ def test_subnets():
|
|||
|
||||
conn.delete_subnet.when.called_with(
|
||||
subnet.id).should.throw(EC2ResponseError)
|
||||
|
||||
|
||||
@mock_ec2
|
||||
def test_subnet_tagging():
|
||||
conn = boto.connect_vpc('the_key', 'the_secret')
|
||||
vpc = conn.create_vpc("10.0.0.0/16")
|
||||
subnet = conn.create_subnet(vpc.id, "10.0.0.0/18")
|
||||
|
||||
subnet.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 subnet
|
||||
subnet = conn.get_all_subnets()[0]
|
||||
subnet.tags.should.have.length_of(1)
|
||||
subnet.tags["a key"].should.equal("some value")
|
||||
|
|
|
|||
|
|
@ -21,3 +21,20 @@ def test_vpcs():
|
|||
|
||||
conn.delete_vpc.when.called_with(
|
||||
"vpc-1234abcd").should.throw(EC2ResponseError)
|
||||
|
||||
|
||||
@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")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue