diff options
author | Daniel Lindsley <daniel@toastdriven.com> | 2013-09-12 15:42:59 -0700 |
---|---|---|
committer | Daniel Lindsley <daniel@toastdriven.com> | 2013-09-12 15:42:59 -0700 |
commit | 7b70eafa9c91dfd5842eb6dfa7b7da0fee8074ff (patch) | |
tree | 2576889bebc71596bfd1f723dc08446bae28d703 /tests/unit/ec2/test_networkinterface.py | |
parent | ad40af14b6989f940deac74e0276e8e8a8bd3372 (diff) | |
parent | 0efd52ea646fe536822dcf9d85bfe51cf4b7950a (diff) | |
download | boto-2.13.0.tar.gz |
Merge branch 'release-2.13.0'2.13.0
* release-2.13.0: (21 commits)
Bumping version to 2.13.0
Updated release notes for everything that's been merged.
Added support for modifying reserved instances in EC2.
Added ``dry_run`` to. All. The. Things.
Fixes #1679, #1566 - Altered DDBv2's ``batch_write`` to appropriately queue & retry unprocessed items.
Adding API reference for boto.swf.layer2.
Fixes #1709 - Cannot create Launch Configuration with Block Device Mappings
Removing duplicate boto.s3.prefix entry to prevent Sphinx build errors.
Removed the incomplete copyright notice from the README.
More release notes for recent changes.
Fixes #1664 - Corrected the behavior of ``dynamodb_load`` when working with sets.
document get_all_images magic strings
Added release notes for the recent merges.
SNS ``publish`` now uses POST.
Updated release notes to mention the Opsworks VPC support.
Altered SDB to no longer cause errors when building the docs.
Added Opsworks to the docs & cleaned up a bunch of Sphinx build errors.
Fixed the creation of EC2 VPC instances with public IPs.
Added dev release notes back in, as well as a template for future laziness.
Updated Opsworks docstrings to latest.
...
Diffstat (limited to 'tests/unit/ec2/test_networkinterface.py')
-rw-r--r-- | tests/unit/ec2/test_networkinterface.py | 148 |
1 files changed, 103 insertions, 45 deletions
diff --git a/tests/unit/ec2/test_networkinterface.py b/tests/unit/ec2/test_networkinterface.py index 4674823d..81fa4aef 100644 --- a/tests/unit/ec2/test_networkinterface.py +++ b/tests/unit/ec2/test_networkinterface.py @@ -23,7 +23,7 @@ from tests.unit import unittest - +from boto.exception import BotoClientError from boto.ec2.networkinterface import NetworkInterfaceCollection from boto.ec2.networkinterface import NetworkInterfaceSpecification from boto.ec2.networkinterface import PrivateIPAddress @@ -42,7 +42,8 @@ class TestNetworkInterfaceCollection(unittest.TestCase): description='description1', private_ip_address='10.0.0.54', delete_on_termination=False, private_ip_addresses=[self.private_ip_address1, - self.private_ip_address2]) + self.private_ip_address2] + ) self.private_ip_address3 = PrivateIPAddress( private_ip_address='10.0.1.10', primary=False) @@ -54,8 +55,18 @@ class TestNetworkInterfaceCollection(unittest.TestCase): groups=['group_id1', 'group_id2'], private_ip_address='10.0.1.54', delete_on_termination=False, private_ip_addresses=[self.private_ip_address3, + self.private_ip_address4] + ) + + self.network_interfaces_spec3 = NetworkInterfaceSpecification( + device_index=0, subnet_id='subnet_id2', + description='description2', + groups=['group_id1', 'group_id2'], + private_ip_address='10.0.1.54', delete_on_termination=False, + private_ip_addresses=[self.private_ip_address3, self.private_ip_address4], - associate_public_ip_address=True) + associate_public_ip_address=True + ) def test_param_serialization(self): collection = NetworkInterfaceCollection(self.network_interfaces_spec1, @@ -63,30 +74,29 @@ class TestNetworkInterfaceCollection(unittest.TestCase): params = {} collection.build_list_params(params) self.assertDictEqual(params, { - 'NetworkInterface.1.DeviceIndex': '1', - 'NetworkInterface.1.DeleteOnTermination': 'false', - 'NetworkInterface.1.Description': 'description1', - 'NetworkInterface.1.PrivateIpAddress': '10.0.0.54', - 'NetworkInterface.1.SubnetId': 'subnet_id', - 'NetworkInterface.1.PrivateIpAddresses.1.Primary': 'false', - 'NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress': + 'NetworkInterface.0.DeviceIndex': '1', + 'NetworkInterface.0.DeleteOnTermination': 'false', + 'NetworkInterface.0.Description': 'description1', + 'NetworkInterface.0.PrivateIpAddress': '10.0.0.54', + 'NetworkInterface.0.SubnetId': 'subnet_id', + 'NetworkInterface.0.PrivateIpAddresses.0.Primary': 'false', + 'NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress': '10.0.0.10', - 'NetworkInterface.1.PrivateIpAddresses.2.Primary': 'false', - 'NetworkInterface.1.PrivateIpAddresses.2.PrivateIpAddress': + 'NetworkInterface.0.PrivateIpAddresses.1.Primary': 'false', + 'NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress': '10.0.0.11', - 'NetworkInterface.2.DeviceIndex': '2', - 'NetworkInterface.2.Description': 'description2', - 'NetworkInterface.2.DeleteOnTermination': 'false', - 'NetworkInterface.2.PrivateIpAddress': '10.0.1.54', - 'NetworkInterface.2.SubnetId': 'subnet_id2', - 'NetworkInterface.2.AssociatePublicIpAddress': 'true', - 'NetworkInterface.2.SecurityGroupId.1': 'group_id1', - 'NetworkInterface.2.SecurityGroupId.2': 'group_id2', - 'NetworkInterface.2.PrivateIpAddresses.1.Primary': 'false', - 'NetworkInterface.2.PrivateIpAddresses.1.PrivateIpAddress': + 'NetworkInterface.1.DeviceIndex': '2', + 'NetworkInterface.1.Description': 'description2', + 'NetworkInterface.1.DeleteOnTermination': 'false', + 'NetworkInterface.1.PrivateIpAddress': '10.0.1.54', + 'NetworkInterface.1.SubnetId': 'subnet_id2', + 'NetworkInterface.1.SecurityGroupId.0': 'group_id1', + 'NetworkInterface.1.SecurityGroupId.1': 'group_id2', + 'NetworkInterface.1.PrivateIpAddresses.0.Primary': 'false', + 'NetworkInterface.1.PrivateIpAddresses.0.PrivateIpAddress': '10.0.1.10', - 'NetworkInterface.2.PrivateIpAddresses.2.Primary': 'false', - 'NetworkInterface.2.PrivateIpAddresses.2.PrivateIpAddress': + 'NetworkInterface.1.PrivateIpAddresses.1.Primary': 'false', + 'NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress': '10.0.1.11', }) @@ -99,44 +109,92 @@ class TestNetworkInterfaceCollection(unittest.TestCase): # we're just checking a few keys to make sure we get the proper # prefix. self.assertDictEqual(params, { - 'LaunchSpecification.NetworkInterface.1.DeviceIndex': '1', - 'LaunchSpecification.NetworkInterface.1.DeleteOnTermination': + 'LaunchSpecification.NetworkInterface.0.DeviceIndex': '1', + 'LaunchSpecification.NetworkInterface.0.DeleteOnTermination': 'false', - 'LaunchSpecification.NetworkInterface.1.Description': + 'LaunchSpecification.NetworkInterface.0.Description': 'description1', - 'LaunchSpecification.NetworkInterface.1.PrivateIpAddress': + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddress': '10.0.0.54', - 'LaunchSpecification.NetworkInterface.1.SubnetId': 'subnet_id', - 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.Primary': + 'LaunchSpecification.NetworkInterface.0.SubnetId': 'subnet_id', + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.Primary': 'false', - 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress': + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress': '10.0.0.10', - 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.2.Primary': 'false', - 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.2.PrivateIpAddress': + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.Primary': 'false', + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress': '10.0.0.11', - 'LaunchSpecification.NetworkInterface.2.DeviceIndex': '2', - 'LaunchSpecification.NetworkInterface.2.Description': + 'LaunchSpecification.NetworkInterface.1.DeviceIndex': '2', + 'LaunchSpecification.NetworkInterface.1.Description': 'description2', - 'LaunchSpecification.NetworkInterface.2.DeleteOnTermination': + 'LaunchSpecification.NetworkInterface.1.DeleteOnTermination': 'false', - 'LaunchSpecification.NetworkInterface.2.PrivateIpAddress': + 'LaunchSpecification.NetworkInterface.1.PrivateIpAddress': '10.0.1.54', - 'LaunchSpecification.NetworkInterface.2.SubnetId': 'subnet_id2', - 'LaunchSpecification.NetworkInterface.2.AssociatePublicIpAddress': 'true', - 'LaunchSpecification.NetworkInterface.2.SecurityGroupId.1': + 'LaunchSpecification.NetworkInterface.1.SubnetId': 'subnet_id2', + 'LaunchSpecification.NetworkInterface.1.SecurityGroupId.0': 'group_id1', - 'LaunchSpecification.NetworkInterface.2.SecurityGroupId.2': + 'LaunchSpecification.NetworkInterface.1.SecurityGroupId.1': 'group_id2', - 'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.1.Primary': + 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.0.Primary': 'false', - 'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.1.PrivateIpAddress': + 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.0.PrivateIpAddress': '10.0.1.10', - 'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.2.Primary': + 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.Primary': 'false', - 'LaunchSpecification.NetworkInterface.2.PrivateIpAddresses.2.PrivateIpAddress': + 'LaunchSpecification.NetworkInterface.1.PrivateIpAddresses.1.PrivateIpAddress': '10.0.1.11', }) + def test_cant_use_public_ip(self): + collection = NetworkInterfaceCollection(self.network_interfaces_spec3, + self.network_interfaces_spec1) + params = {} + + # First, verify we can't incorrectly create multiple interfaces with + # on having a public IP. + with self.assertRaises(BotoClientError): + collection.build_list_params(params, prefix='LaunchSpecification.') + + # Next, ensure it can't be on device index 1. + self.network_interfaces_spec3.device_index = 1 + collection = NetworkInterfaceCollection(self.network_interfaces_spec3) + params = {} + + with self.assertRaises(BotoClientError): + collection.build_list_params(params, prefix='LaunchSpecification.') + + def test_public_ip(self): + # With public IP. + collection = NetworkInterfaceCollection(self.network_interfaces_spec3) + params = {} + collection.build_list_params(params, prefix='LaunchSpecification.') + + self.assertDictEqual(params, { + 'LaunchSpecification.NetworkInterface.0.AssociatePublicIpAddress': + 'true', + 'LaunchSpecification.NetworkInterface.0.DeviceIndex': '0', + 'LaunchSpecification.NetworkInterface.0.DeleteOnTermination': + 'false', + 'LaunchSpecification.NetworkInterface.0.Description': + 'description2', + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddress': + '10.0.1.54', + 'LaunchSpecification.NetworkInterface.0.SubnetId': 'subnet_id2', + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.Primary': + 'false', + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.0.PrivateIpAddress': + '10.0.1.10', + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.Primary': + 'false', + 'LaunchSpecification.NetworkInterface.0.PrivateIpAddresses.1.PrivateIpAddress': + '10.0.1.11', + 'LaunchSpecification.NetworkInterface.0.SecurityGroupId.0': + 'group_id1', + 'LaunchSpecification.NetworkInterface.0.SecurityGroupId.1': + 'group_id2', + }) + if __name__ == '__main__': unittest.main() |