summaryrefslogtreecommitdiff
path: root/tests/unit/ec2
diff options
context:
space:
mode:
authorkyleknap <kyleknap@amazon.com>2014-10-08 12:41:04 -0700
committerkyleknap <kyleknap@amazon.com>2014-10-08 12:41:04 -0700
commit2517f660f8ef9012708d46da3a36ab967993d2f6 (patch)
treed90281aecdf962a2c7342938ac0a20d57fb74088 /tests/unit/ec2
parentff3d8159af3c816303785e023a4182aacb6aabf5 (diff)
parent8f500ce75fea1ba1446195b26dddbe90b52223d8 (diff)
downloadboto-2.33.0.tar.gz
Merge branch 'release-2.33.0'2.33.0
Diffstat (limited to 'tests/unit/ec2')
-rw-r--r--[-rwxr-xr-x]tests/unit/ec2/autoscale/test_group.py60
-rw-r--r--tests/unit/ec2/elb/test_attribute.py38
-rw-r--r--tests/unit/ec2/elb/test_listener.py24
-rw-r--r--tests/unit/ec2/elb/test_loadbalancer.py1
-rw-r--r--tests/unit/ec2/test_address.py71
-rw-r--r--tests/unit/ec2/test_blockdevicemapping.py17
-rwxr-xr-xtests/unit/ec2/test_connection.py189
-rw-r--r--tests/unit/ec2/test_ec2object.py82
-rw-r--r--tests/unit/ec2/test_instance.py3
-rw-r--r--tests/unit/ec2/test_instancestatus.py2
-rw-r--r--tests/unit/ec2/test_instancetype.py2
-rw-r--r--tests/unit/ec2/test_networkinterface.py4
-rw-r--r--tests/unit/ec2/test_securitygroup.py3
-rw-r--r--tests/unit/ec2/test_spotinstance.py4
-rw-r--r--tests/unit/ec2/test_volume.py11
15 files changed, 347 insertions, 164 deletions
diff --git a/tests/unit/ec2/autoscale/test_group.py b/tests/unit/ec2/autoscale/test_group.py
index 73f2ccf8..5c5b4dcd 100755..100644
--- a/tests/unit/ec2/autoscale/test_group.py
+++ b/tests/unit/ec2/autoscale/test_group.py
@@ -36,6 +36,7 @@ from boto.ec2.blockdevicemapping import EBSBlockDeviceType, BlockDeviceMapping
from boto.ec2.autoscale import launchconfig, LaunchConfiguration
+
class TestAutoScaleGroup(AWSMockServiceTestCase):
connection_class = AutoScaleConnection
@@ -80,7 +81,7 @@ class TestAutoScaleGroup(AWSMockServiceTestCase):
'Action': 'CreateAutoScalingGroup',
'AutoScalingGroupName': 'foo',
'VPCZoneIdentifier': 'vpc_zone_1',
- }, ignore_params_values=['MaxSize', 'MinSize', 'LaunchConfigurationName', 'Version'])
+ }, ignore_params_values=['MaxSize', 'MinSize', 'LaunchConfigurationName', 'Version'])
def test_autoscaling_group_vpc_zone_identifier_list(self):
self.set_http_response(status_code=200)
@@ -92,7 +93,7 @@ class TestAutoScaleGroup(AWSMockServiceTestCase):
'Action': 'CreateAutoScalingGroup',
'AutoScalingGroupName': 'foo',
'VPCZoneIdentifier': 'vpc_zone_1,vpc_zone_2',
- }, ignore_params_values=['MaxSize', 'MinSize', 'LaunchConfigurationName', 'Version'])
+ }, ignore_params_values=['MaxSize', 'MinSize', 'LaunchConfigurationName', 'Version'])
def test_autoscaling_group_vpc_zone_identifier_multi(self):
self.set_http_response(status_code=200)
@@ -104,7 +105,7 @@ class TestAutoScaleGroup(AWSMockServiceTestCase):
'Action': 'CreateAutoScalingGroup',
'AutoScalingGroupName': 'foo',
'VPCZoneIdentifier': 'vpc_zone_1,vpc_zone_2',
- }, ignore_params_values=['MaxSize', 'MinSize', 'LaunchConfigurationName', 'Version'])
+ }, ignore_params_values=['MaxSize', 'MinSize', 'LaunchConfigurationName', 'Version'])
class TestAutoScaleGroupHonorCooldown(AWSMockServiceTestCase):
@@ -129,6 +130,7 @@ class TestAutoScaleGroupHonorCooldown(AWSMockServiceTestCase):
'HonorCooldown': 'true',
}, ignore_params_values=['Version'])
+
class TestScheduledGroup(AWSMockServiceTestCase):
connection_class = AutoScaleConnection
@@ -166,6 +168,7 @@ class TestScheduledGroup(AWSMockServiceTestCase):
'Recurrence': '0 10 * * *',
}, ignore_params_values=['Version'])
+
class TestParseAutoScaleGroupResponse(AWSMockServiceTestCase):
connection_class = AutoScaleConnection
@@ -264,6 +267,7 @@ class TestDescribeTerminationPolicies(AWSMockServiceTestCase):
['ClosestToNextInstanceHour', 'Default',
'NewestInstance', 'OldestInstance', 'OldestLaunchConfiguration'])
+
class TestLaunchConfigurationDescribe(AWSMockServiceTestCase):
connection_class = AutoScaleConnection
@@ -332,6 +336,7 @@ class TestLaunchConfigurationDescribe(AWSMockServiceTestCase):
'LaunchConfigurationNames.member.2': 'my-test2'
}, ignore_params_values=['Version'])
+
class TestLaunchConfiguration(AWSMockServiceTestCase):
connection_class = AutoScaleConnection
@@ -346,26 +351,24 @@ class TestLaunchConfiguration(AWSMockServiceTestCase):
# This unit test is based on #753 and #1343
self.set_http_response(status_code=200)
dev_sdf = EBSBlockDeviceType(snapshot_id='snap-12345')
- dev_sdg = EBSBlockDeviceType(snapshot_id='snap-12346')
bdm = BlockDeviceMapping()
bdm['/dev/sdf'] = dev_sdf
- bdm['/dev/sdg'] = dev_sdg
lc = launchconfig.LaunchConfiguration(
- connection=self.service_connection,
- name='launch_config',
- image_id='123456',
- instance_type = 'm1.large',
- user_data = '#!/bin/bash',
- security_groups = ['group1', 'group2'],
- spot_price='price',
- block_device_mappings = [bdm],
- associate_public_ip_address = True,
- volume_type='atype',
- delete_on_termination=False,
- iops=3000
- )
+ connection=self.service_connection,
+ name='launch_config',
+ image_id='123456',
+ instance_type='m1.large',
+ user_data='#!/bin/bash',
+ security_groups=['group1'],
+ spot_price='price',
+ block_device_mappings=[bdm],
+ associate_public_ip_address=True,
+ volume_type='atype',
+ delete_on_termination=False,
+ iops=3000
+ )
response = self.service_connection.create_launch_configuration(lc)
@@ -374,19 +377,15 @@ class TestLaunchConfiguration(AWSMockServiceTestCase):
'BlockDeviceMappings.member.1.DeviceName': '/dev/sdf',
'BlockDeviceMappings.member.1.Ebs.DeleteOnTermination': 'false',
'BlockDeviceMappings.member.1.Ebs.SnapshotId': 'snap-12345',
- 'BlockDeviceMappings.member.2.DeviceName': '/dev/sdg',
- 'BlockDeviceMappings.member.2.Ebs.DeleteOnTermination': 'false',
- 'BlockDeviceMappings.member.2.Ebs.SnapshotId': 'snap-12346',
'EbsOptimized': 'false',
'LaunchConfigurationName': 'launch_config',
'ImageId': '123456',
- 'UserData': base64.b64encode('#!/bin/bash').decode('utf-8'),
+ 'UserData': base64.b64encode(b'#!/bin/bash').decode('utf-8'),
'InstanceMonitoring.Enabled': 'false',
'InstanceType': 'm1.large',
'SecurityGroups.member.1': 'group1',
- 'SecurityGroups.member.2': 'group2',
'SpotPrice': 'price',
- 'AssociatePublicIpAddress' : 'true',
+ 'AssociatePublicIpAddress': 'true',
'VolumeType': 'atype',
'DeleteOnTermination': 'false',
'Iops': 3000,
@@ -526,6 +525,7 @@ class TestDeleteNotificationConfiguration(AWSMockServiceTestCase):
'TopicARN': 'arn:aws:sns:us-east-1:19890506:AutoScaling-Up',
}, ignore_params_values=['Version'])
+
class TestAutoScalingTag(AWSMockServiceTestCase):
connection_class = AutoScaleConnection
@@ -549,7 +549,7 @@ class TestAutoScalingTag(AWSMockServiceTestCase):
resource_id='sg-00000000',
resource_type='auto-scaling-group',
propagate_at_launch=True
- ),
+ ),
Tag(
connection=self.service_connection,
key='bravo',
@@ -557,8 +557,7 @@ class TestAutoScalingTag(AWSMockServiceTestCase):
resource_id='sg-00000000',
resource_type='auto-scaling-group',
propagate_at_launch=False
- )]
-
+ )]
response = self.service_connection.create_or_update_tags(tags)
@@ -585,7 +584,6 @@ class TestAutoScalingTag(AWSMockServiceTestCase):
('PropagateAtLaunch', 'true', 'propagate_at_launch')]:
self.check_tag_attributes_set(i[0], i[1], i[2])
-
def check_tag_attributes_set(self, name, value, attr):
tag = Tag()
tag.endElement(name, value, None)
@@ -613,8 +611,8 @@ class TestAttachInstances(AWSMockServiceTestCase):
def test_attach_instances(self):
self.set_http_response(status_code=200)
self.service_connection.attach_instances(
- 'autoscale',
- ['inst2', 'inst1', 'inst4']
+ 'autoscale',
+ ['inst2', 'inst1', 'inst4']
)
self.assert_request_parameters({
'Action': 'AttachInstances',
@@ -651,6 +649,7 @@ class TestGetAccountLimits(AWSMockServiceTestCase):
self.assertEqual(limits.max_autoscaling_groups, 6)
self.assertEqual(limits.max_launch_configurations, 3)
+
class TestGetAdjustmentTypes(AWSMockServiceTestCase):
connection_class = AutoScaleConnection
@@ -678,6 +677,7 @@ class TestGetAdjustmentTypes(AWSMockServiceTestCase):
</ResponseMetadata>
</DescribeAdjustmentTypesResponse>
"""
+
def test_autoscaling_adjustment_types(self):
self.set_http_response(status_code=200)
response = self.service_connection.get_all_adjustment_types()
diff --git a/tests/unit/ec2/elb/test_attribute.py b/tests/unit/ec2/elb/test_attribute.py
index 78d32709..40edecba 100644
--- a/tests/unit/ec2/elb/test_attribute.py
+++ b/tests/unit/ec2/elb/test_attribute.py
@@ -35,6 +35,21 @@ ATTRIBUTE_GET_FALSE_CZL_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
</DescribeLoadBalancerAttributesResponse>
"""
+ATTRIBUTE_GET_CS_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
+<DescribeLoadBalancerAttributesResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
+ <DescribeLoadBalancerAttributesResult>
+ <LoadBalancerAttributes>
+ <ConnectionSettings>
+ <IdleTimeout>30</IdleTimeout>
+ </ConnectionSettings>
+ </LoadBalancerAttributes>
+ </DescribeLoadBalancerAttributesResult>
+<ResponseMetadata>
+ <RequestId>83c88b9d-12b7-11e3-8b82-87b12EXAMPLE</RequestId>
+</ResponseMetadata>
+</DescribeLoadBalancerAttributesResponse>
+"""
+
ATTRIBUTE_SET_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
<ModifyLoadBalancerAttributesResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
<ModifyLoadBalancerAttributesResult/>
@@ -63,7 +78,10 @@ ATTRIBUTE_TESTS = [
[('cross_zone_load_balancing.enabled', True)]),
(ATTRIBUTE_GET_FALSE_CZL_RESPONSE,
[('cross_zone_load_balancing.enabled', False)]),
- ]
+ (ATTRIBUTE_GET_CS_RESPONSE,
+ [('connecting_settings.idle_timeout', 30)]),
+]
+
class TestLbAttributes(unittest.TestCase):
"""Tests LB Attributes."""
@@ -103,8 +121,7 @@ class TestLbAttributes(unittest.TestCase):
tests = [
('crossZoneLoadBalancing', True, ATTRIBUTE_GET_TRUE_CZL_RESPONSE),
('crossZoneLoadBalancing', False, ATTRIBUTE_GET_FALSE_CZL_RESPONSE),
- ]
-
+ ]
for attr, value, response in tests:
mock_response.read.return_value = response
@@ -118,7 +135,7 @@ class TestLbAttributes(unittest.TestCase):
tests = [
('crossZoneLoadBalancing', True, ATTRIBUTE_SET_CZL_TRUE_REQUEST),
('crossZoneLoadBalancing', False, ATTRIBUTE_SET_CZL_FALSE_REQUEST),
- ]
+ ]
for attr, value, args in tests:
mock_response.read.return_value = ATTRIBUTE_SET_RESPONSE
@@ -151,7 +168,7 @@ class TestLbAttributes(unittest.TestCase):
# Gets a false result.
(lb.is_cross_zone_load_balancing, [True], False,
ATTRIBUTE_GET_FALSE_CZL_RESPONSE),
- ]
+ ]
for method, args, result, response in tests:
mock_response.read.return_value = response
@@ -173,5 +190,16 @@ class TestLbAttributes(unittest.TestCase):
self.assertTrue(lb.disable_cross_zone_load_balancing())
elb.make_request.assert_called_with(*ATTRIBUTE_SET_CZL_FALSE_REQUEST)
+ def test_lb_get_connection_settings(self):
+ """Tests checking connectionSettings attribute"""
+ mock_response, elb, _ = self._setup_mock()
+
+ attrs = [('idle_timeout', 30), ]
+ mock_response.read.return_value = ATTRIBUTE_GET_CS_RESPONSE
+ attributes = elb.get_all_lb_attributes('test_elb')
+ self.assertTrue(isinstance(attributes, LbAttributes))
+ for attr, value in attrs:
+ self.assertEqual(getattr(attributes.connecting_settings, attr), value)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/unit/ec2/elb/test_listener.py b/tests/unit/ec2/elb/test_listener.py
index 16aa67fc..a9d29c5b 100644
--- a/tests/unit/ec2/elb/test_listener.py
+++ b/tests/unit/ec2/elb/test_listener.py
@@ -4,6 +4,7 @@ from tests.unit import unittest
import boto.resultset
from boto.ec2.elb.loadbalancer import LoadBalancer
+from boto.ec2.elb.listener import Listener
LISTENERS_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
@@ -96,6 +97,29 @@ class TestListenerResponseParsing(unittest.TestCase):
]
)
+class TestListenerGetItem(unittest.TestCase):
+ def test_getitem_for_http_listener(self):
+ listener = Listener(load_balancer_port=80,
+ instance_port=80,
+ protocol='HTTP',
+ instance_protocol='HTTP')
+ self.assertEqual(listener[0], 80)
+ self.assertEqual(listener[1], 80)
+ self.assertEqual(listener[2], 'HTTP')
+ self.assertEqual(listener[3], 'HTTP')
+
+ def test_getitem_for_https_listener(self):
+ listener = Listener(load_balancer_port=443,
+ instance_port=80,
+ protocol='HTTPS',
+ instance_protocol='HTTP',
+ ssl_certificate_id='look_at_me_im_an_arn')
+ self.assertEqual(listener[0], 443)
+ self.assertEqual(listener[1], 80)
+ self.assertEqual(listener[2], 'HTTPS')
+ self.assertEqual(listener[3], 'HTTP')
+ self.assertEqual(listener[4], 'look_at_me_im_an_arn')
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/unit/ec2/elb/test_loadbalancer.py b/tests/unit/ec2/elb/test_loadbalancer.py
index 98ea71f6..a042df48 100644
--- a/tests/unit/ec2/elb/test_loadbalancer.py
+++ b/tests/unit/ec2/elb/test_loadbalancer.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
from tests.unit import unittest
-from tests.unit import AWSMockServiceTestCase
from tests.compat import mock
from boto.ec2.elb import ELBConnection
diff --git a/tests/unit/ec2/test_address.py b/tests/unit/ec2/test_address.py
index 147040a0..519918e7 100644
--- a/tests/unit/ec2/test_address.py
+++ b/tests/unit/ec2/test_address.py
@@ -2,6 +2,7 @@ from tests.compat import mock, unittest
from boto.ec2.address import Address
+
class AddressTest(unittest.TestCase):
def setUp(self):
self.address = Address()
@@ -21,27 +22,28 @@ class AddressTest(unittest.TestCase):
("somethingRandom", "somethingRandom", "somethingRandom")]:
self.check_that_attribute_has_been_set(arguments[0], arguments[1], arguments[2])
-
def test_release_calls_connection_release_address_with_correct_args(self):
self.address.release()
self.address.connection.release_address.assert_called_with(
- "192.168.1.1",
+ public_ip="192.168.1.1",
dry_run=False
)
def test_associate_calls_connection_associate_address_with_correct_args(self):
self.address.associate(1)
self.address.connection.associate_address.assert_called_with(
- 1,
- "192.168.1.1",
+ instance_id=1,
+ public_ip="192.168.1.1",
allow_reassociation=False,
+ network_interface_id=None,
+ private_ip_address=None,
dry_run=False
)
def test_disassociate_calls_connection_disassociate_address_with_correct_args(self):
self.address.disassociate()
self.address.connection.disassociate_address.assert_called_with(
- "192.168.1.1",
+ public_ip="192.168.1.1",
dry_run=False
)
@@ -66,20 +68,67 @@ class AddressWithAllocationTest(unittest.TestCase):
("somethingRandom", "somethingRandom", "somethingRandom")]:
self.check_that_attribute_has_been_set(arguments[0], arguments[1], arguments[2])
-
def test_release_calls_connection_release_address_with_correct_args(self):
self.address.release()
self.address.connection.release_address.assert_called_with(
- None,
- "aid1",
+ allocation_id="aid1",
dry_run=False
)
def test_associate_calls_connection_associate_address_with_correct_args(self):
self.address.associate(1)
self.address.connection.associate_address.assert_called_with(
- 1,
- "192.168.1.1",
+ instance_id=1,
+ public_ip="192.168.1.1",
+ allocation_id="aid1",
+ network_interface_id=None,
+ private_ip_address=None,
+ allow_reassociation=False,
+ dry_run=False
+ )
+
+ def test_disassociate_calls_connection_disassociate_address_with_correct_args(self):
+ self.address.disassociate()
+ self.address.connection.disassociate_address.assert_called_with(
+ public_ip="192.168.1.1",
+ dry_run=False
+ )
+
+class AddressWithNetworkInterfaceTest(unittest.TestCase):
+ def setUp(self):
+ self.address = Address()
+ self.address.connection = mock.Mock()
+ self.address.public_ip = "192.168.1.1"
+ self.address.allocation_id = "aid1"
+
+ def check_that_attribute_has_been_set(self, name, value, attribute):
+ self.address.endElement(name, value, None)
+ self.assertEqual(getattr(self.address, attribute), value)
+
+ def test_endElement_sets_correct_attributes_with_values(self):
+ for arguments in [("publicIp", "192.168.1.1", "public_ip"),
+ ("instanceId", 1, "instance_id"),
+ ("domain", "some domain", "domain"),
+ ("allocationId", 1, "allocation_id"),
+ ("associationId", 1, "association_id"),
+ ("somethingRandom", "somethingRandom", "somethingRandom")]:
+ self.check_that_attribute_has_been_set(arguments[0], arguments[1], arguments[2])
+
+
+ def test_release_calls_connection_release_address_with_correct_args(self):
+ self.address.release()
+ self.address.connection.release_address.assert_called_with(
+ allocation_id="aid1",
+ dry_run=False
+ )
+
+ def test_associate_calls_connection_associate_address_with_correct_args(self):
+ self.address.associate(network_interface_id=1)
+ self.address.connection.associate_address.assert_called_with(
+ instance_id=None,
+ public_ip="192.168.1.1",
+ network_interface_id=1,
+ private_ip_address=None,
allocation_id="aid1",
allow_reassociation=False,
dry_run=False
@@ -88,7 +137,7 @@ class AddressWithAllocationTest(unittest.TestCase):
def test_disassociate_calls_connection_disassociate_address_with_correct_args(self):
self.address.disassociate()
self.address.connection.disassociate_address.assert_called_with(
- "192.168.1.1",
+ public_ip="192.168.1.1",
dry_run=False
)
diff --git a/tests/unit/ec2/test_blockdevicemapping.py b/tests/unit/ec2/test_blockdevicemapping.py
index fa91fa3e..83cdf184 100644
--- a/tests/unit/ec2/test_blockdevicemapping.py
+++ b/tests/unit/ec2/test_blockdevicemapping.py
@@ -1,4 +1,4 @@
-from tests.compat import mock, unittest
+from tests.compat import unittest
from boto.ec2.connection import EC2Connection
from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
@@ -41,6 +41,15 @@ class BlockDeviceTypeTests(unittest.TestCase):
self.block_device_type.endElement("deleteOnTermination", 'something else', None)
self.assertEqual(self.block_device_type.delete_on_termination, False)
+ def test_endElement_with_name_encrypted_value_true(self):
+ self.block_device_type.endElement("Encrypted", "true", None)
+ self.assertEqual(self.block_device_type.encrypted, True)
+
+ def test_endElement_with_name_Encrypted_value_other(self):
+ self.block_device_type.endElement("Encrypted", 'something else', None)
+ self.assertEqual(self.block_device_type.encrypted, False)
+
+
class BlockDeviceMappingTests(unittest.TestCase):
def setUp(self):
self.block_device_mapping = BlockDeviceMapping()
@@ -55,7 +64,8 @@ class BlockDeviceMappingTests(unittest.TestCase):
b1.status == b2.status,
b1.attach_time == b2.attach_time,
b1.delete_on_termination == b2.delete_on_termination,
- b1.size == b2.size])
+ b1.size == b2.size,
+ b1.encrypted == b2.encrypted])
def test_startElement_with_name_ebs_sets_and_returns_current_value(self):
retval = self.block_device_mapping.startElement("ebs", None, None)
@@ -96,7 +106,7 @@ class TestLaunchConfiguration(AWSMockServiceTestCase):
# Autoscaling).
self.set_http_response(status_code=200)
dev_sdf = BlockDeviceType(snapshot_id='snap-12345')
- dev_sdg = BlockDeviceType(snapshot_id='snap-12346', delete_on_termination=True)
+ dev_sdg = BlockDeviceType(snapshot_id='snap-12346', delete_on_termination=True, encrypted=True)
class OrderedBlockDeviceMapping(OrderedDict, BlockDeviceMapping):
pass
@@ -119,6 +129,7 @@ class TestLaunchConfiguration(AWSMockServiceTestCase):
'BlockDeviceMapping.2.DeviceName': '/dev/sdg',
'BlockDeviceMapping.2.Ebs.DeleteOnTermination': 'true',
'BlockDeviceMapping.2.Ebs.SnapshotId': 'snap-12346',
+ 'BlockDeviceMapping.2.Ebs.Encrypted': 'true',
'ImageId': '123456',
'InstanceType': 'm1.large',
'MaxCount': 1,
diff --git a/tests/unit/ec2/test_connection.py b/tests/unit/ec2/test_connection.py
index e3e4fa35..287e1a72 100755
--- a/tests/unit/ec2/test_connection.py
+++ b/tests/unit/ec2/test_connection.py
@@ -105,7 +105,7 @@ class TestReservedInstanceOfferings(TestEC2ConnectionBase):
def test_get_reserved_instance_offerings_params(self):
self.set_http_response(status_code=200)
self.ec2.get_all_reserved_instances_offerings(
- reserved_instances_offering_ids=['id1','id2'],
+ reserved_instances_offering_ids=['id1', 'id2'],
instance_type='t1.micro',
availability_zone='us-east-1',
product_description='description',
@@ -132,9 +132,9 @@ class TestReservedInstanceOfferings(TestEC2ConnectionBase):
'MaxDuration': '1000',
'MaxInstanceCount': '1',
'NextToken': 'next_token',
- 'MaxResults': '10',},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ 'MaxResults': '10', },
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
class TestPurchaseReservedInstanceOffering(TestEC2ConnectionBase):
@@ -144,16 +144,16 @@ class TestPurchaseReservedInstanceOffering(TestEC2ConnectionBase):
def test_serialized_api_args(self):
self.set_http_response(status_code=200)
response = self.ec2.purchase_reserved_instance_offering(
- 'offering_id', 1, (100.0, 'USD'))
+ 'offering_id', 1, (100.0, 'USD'))
self.assert_request_parameters({
'Action': 'PurchaseReservedInstancesOffering',
'InstanceCount': 1,
'ReservedInstancesOfferingId': 'offering_id',
'LimitPrice.Amount': '100.0',
- 'LimitPrice.CurrencyCode': 'USD',},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ 'LimitPrice.CurrencyCode': 'USD', },
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
class TestCreateImage(TestEC2ConnectionBase):
@@ -166,30 +166,30 @@ class TestCreateImage(TestEC2ConnectionBase):
def test_minimal(self):
self.set_http_response(status_code=200)
response = self.ec2.create_image(
- 'instance_id', 'name')
+ 'instance_id', 'name')
self.assert_request_parameters({
'Action': 'CreateImage',
'InstanceId': 'instance_id',
'Name': 'name'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
def test_block_device_mapping(self):
self.set_http_response(status_code=200)
bdm = BlockDeviceMapping()
bdm['test'] = BlockDeviceType()
response = self.ec2.create_image(
- 'instance_id', 'name', block_device_mapping=bdm)
+ 'instance_id', 'name', block_device_mapping=bdm)
self.assert_request_parameters({
'Action': 'CreateImage',
'InstanceId': 'instance_id',
'Name': 'name',
'BlockDeviceMapping.1.DeviceName': 'test',
'BlockDeviceMapping.1.Ebs.DeleteOnTermination': 'false'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
class TestCancelReservedInstancesListing(TestEC2ConnectionBase):
@@ -414,10 +414,10 @@ class TestCreateReservedInstancesListing(TestEC2ConnectionBase):
'PriceSchedules.0.Price': '2.5',
'PriceSchedules.0.Term': '11',
'PriceSchedules.1.Price': '2.0',
- 'PriceSchedules.1.Term': '8',},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ 'PriceSchedules.1.Term': '8', },
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
class TestDescribeSpotInstanceRequests(TestEC2ConnectionBase):
@@ -517,9 +517,10 @@ class TestCopySnapshot(TestEC2ConnectionBase):
'Description': 'description',
'SourceRegion': 'us-west-2',
'SourceSnapshotId': 'snap-id'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
class TestCopyImage(TestEC2ConnectionBase):
def default_body(self):
@@ -533,7 +534,7 @@ class TestCopyImage(TestEC2ConnectionBase):
def test_copy_image(self):
self.set_http_response(status_code=200)
copied_ami = self.ec2.copy_image('us-west-2', 'ami-id',
- 'name', 'description', 'client-token')
+ 'name', 'description', 'client-token')
self.assertEqual(copied_ami.image_id, 'ami-copied-id')
self.assert_request_parameters({
@@ -543,9 +544,10 @@ class TestCopyImage(TestEC2ConnectionBase):
'SourceRegion': 'us-west-2',
'SourceImageId': 'ami-id',
'ClientToken': 'client-token'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
def test_copy_image_without_name(self):
self.set_http_response(status_code=200)
copied_ami = self.ec2.copy_image('us-west-2', 'ami-id',
@@ -559,9 +561,10 @@ class TestCopyImage(TestEC2ConnectionBase):
'SourceRegion': 'us-west-2',
'SourceImageId': 'ami-id',
'ClientToken': 'client-token'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
class TestAccountAttributes(TestEC2ConnectionBase):
def default_body(self):
@@ -643,10 +646,10 @@ class TestDescribeVPCAttribute(TestEC2ConnectionBase):
self.assert_request_parameters({
'Action': 'DescribeVpcAttribute',
'VpcId': 'vpc-id',
- 'Attribute': 'enableDnsHostnames',},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ 'Attribute': 'enableDnsHostnames', },
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
class TestGetAllNetworkInterfaces(TestEC2ConnectionBase):
@@ -709,8 +712,8 @@ class TestGetAllNetworkInterfaces(TestEC2ConnectionBase):
'Action': 'DescribeNetworkInterfaces',
'NetworkInterfaceId.1': 'eni-0f62d866'},
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
self.assertEqual(len(result), 1)
self.assertEqual(result[0].id, 'eni-0f62d866')
@@ -720,6 +723,7 @@ class TestGetAllNetworkInterfaces(TestEC2ConnectionBase):
self.assertEqual(5, parsed[0].attachment.device_index)
+
class TestGetAllImages(TestEC2ConnectionBase):
def default_body(self):
return b"""
@@ -830,9 +834,9 @@ class TestModifyInterfaceAttribute(TestEC2ConnectionBase):
'Action': 'ModifyNetworkInterfaceAttribute',
'NetworkInterfaceId': 'id',
'Description.Value': 'foo'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
def test_modify_source_dest_check_bool(self):
self.set_http_response(status_code=200)
@@ -843,9 +847,9 @@ class TestModifyInterfaceAttribute(TestEC2ConnectionBase):
'Action': 'ModifyNetworkInterfaceAttribute',
'NetworkInterfaceId': 'id',
'SourceDestCheck.Value': 'true'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
def test_modify_source_dest_check_str(self):
self.set_http_response(status_code=200)
@@ -856,9 +860,9 @@ class TestModifyInterfaceAttribute(TestEC2ConnectionBase):
'Action': 'ModifyNetworkInterfaceAttribute',
'NetworkInterfaceId': 'id',
'SourceDestCheck.Value': 'true'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
def test_modify_source_dest_check_invalid(self):
self.set_http_response(status_code=200)
@@ -879,9 +883,9 @@ class TestModifyInterfaceAttribute(TestEC2ConnectionBase):
'NetworkInterfaceId': 'id',
'Attachment.AttachmentId': 'bar',
'Attachment.DeleteOnTermination': 'true'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
def test_modify_delete_on_termination_bool(self):
self.set_http_response(status_code=200)
@@ -895,9 +899,9 @@ class TestModifyInterfaceAttribute(TestEC2ConnectionBase):
'NetworkInterfaceId': 'id',
'Attachment.AttachmentId': 'bar',
'Attachment.DeleteOnTermination': 'false'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
def test_modify_delete_on_termination_invalid(self):
self.set_http_response(status_code=200)
@@ -918,9 +922,9 @@ class TestModifyInterfaceAttribute(TestEC2ConnectionBase):
'NetworkInterfaceId': 'id',
'SecurityGroupId.1': 'sg-1',
'SecurityGroupId.2': 'sg-2'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
def test_modify_group_set_invalid(self):
self.set_http_response(status_code=200)
@@ -944,7 +948,8 @@ class TestConnectToRegion(unittest.TestCase):
def test_aws_region(self):
region = boto.ec2.RegionData.keys()[0]
- self.ec2 = boto.ec2.connect_to_region(region,
+ self.ec2 = boto.ec2.connect_to_region(
+ region,
https_connection_factory=self.https_connection_factory,
aws_access_key_id='aws_access_key_id',
aws_secret_access_key='aws_secret_access_key'
@@ -952,16 +957,18 @@ class TestConnectToRegion(unittest.TestCase):
self.assertEqual(boto.ec2.RegionData[region], self.ec2.host)
def test_non_aws_region(self):
- self.ec2 = boto.ec2.connect_to_region('foo',
+ self.ec2 = boto.ec2.connect_to_region(
+ 'foo',
https_connection_factory=self.https_connection_factory,
aws_access_key_id='aws_access_key_id',
aws_secret_access_key='aws_secret_access_key',
- region = RegionInfo(name='foo', endpoint='https://foo.com/bar')
+ region=RegionInfo(name='foo', endpoint='https://foo.com/bar')
)
self.assertEqual('https://foo.com/bar', self.ec2.host)
def test_missing_region(self):
- self.ec2 = boto.ec2.connect_to_region('foo',
+ self.ec2 = boto.ec2.connect_to_region(
+ 'foo',
https_connection_factory=self.https_connection_factory,
aws_access_key_id='aws_access_key_id',
aws_secret_access_key='aws_secret_access_key'
@@ -1265,38 +1272,37 @@ class TestRegisterImage(TestEC2ConnectionBase):
'SignatureVersion', 'Timestamp',
'Version'
])
-
+
def test_volume_delete_on_termination_on(self):
self.set_http_response(status_code=200)
self.ec2.register_image('name', 'description',
snapshot_id='snap-12345678',
delete_root_volume_on_termination=True)
-
+
self.assert_request_parameters({
'Action': 'RegisterImage',
'Name': 'name',
'Description': 'description',
'BlockDeviceMapping.1.DeviceName': None,
- 'BlockDeviceMapping.1.Ebs.DeleteOnTermination' : 'true',
+ 'BlockDeviceMapping.1.Ebs.DeleteOnTermination': 'true',
'BlockDeviceMapping.1.Ebs.SnapshotId': 'snap-12345678',
}, ignore_params_values=[
'AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'
])
-
def test_volume_delete_on_termination_default(self):
self.set_http_response(status_code=200)
self.ec2.register_image('name', 'description',
snapshot_id='snap-12345678')
-
+
self.assert_request_parameters({
'Action': 'RegisterImage',
'Name': 'name',
'Description': 'description',
'BlockDeviceMapping.1.DeviceName': None,
- 'BlockDeviceMapping.1.Ebs.DeleteOnTermination' : 'false',
+ 'BlockDeviceMapping.1.Ebs.DeleteOnTermination': 'false',
'BlockDeviceMapping.1.Ebs.SnapshotId': 'snap-12345678',
}, ignore_params_values=[
'AWSAccessKeyId', 'SignatureMethod',
@@ -1344,20 +1350,20 @@ class TestDescribeInstances(TestEC2ConnectionBase):
self.ec2.get_all_instances()
self.assert_request_parameters({
'Action': 'DescribeInstances'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
self.ec2.get_all_reservations()
self.assert_request_parameters({
'Action': 'DescribeInstances'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
self.ec2.get_only_instances()
self.assert_request_parameters({
'Action': 'DescribeInstances'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
def test_max_results(self):
self.set_http_response(status_code=200)
@@ -1367,8 +1373,8 @@ class TestDescribeInstances(TestEC2ConnectionBase):
self.assert_request_parameters({
'Action': 'DescribeInstances',
'MaxResults': 10},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
def test_next_token(self):
self.set_http_response(status_code=200)
@@ -1378,8 +1384,9 @@ class TestDescribeInstances(TestEC2ConnectionBase):
self.assert_request_parameters({
'Action': 'DescribeInstances',
'NextToken': 'abcdefgh'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
+
class TestDescribeTags(TestEC2ConnectionBase):
@@ -1394,8 +1401,8 @@ class TestDescribeTags(TestEC2ConnectionBase):
self.ec2.get_all_tags()
self.assert_request_parameters({
'Action': 'DescribeTags'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
def test_max_results(self):
self.set_http_response(status_code=200)
@@ -1405,8 +1412,8 @@ class TestDescribeTags(TestEC2ConnectionBase):
self.assert_request_parameters({
'Action': 'DescribeTags',
'MaxResults': 10},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp', 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp', 'Version'])
class TestSignatureAlteration(TestEC2ConnectionBase):
@@ -1483,7 +1490,7 @@ class TestDescribeVolumes(TestEC2ConnectionBase):
def default_body(self):
return b"""
<DescribeVolumesResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<volumeSet>
<item>
<volumeId>vol-1a2b3c4d</volumeId>
@@ -1536,9 +1543,9 @@ class TestDescribeVolumes(TestEC2ConnectionBase):
'Action': 'DescribeVolumes',
'VolumeId.1': 'vol-1a2b3c4d',
'VolumeId.2': 'vol-5e6f7a8b'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
self.assertEqual(len(result), 2)
self.assertEqual(result[0].id, 'vol-1a2b3c4d')
self.assertTrue(result[0].encrypted)
@@ -1550,7 +1557,7 @@ class TestDescribeSnapshots(TestEC2ConnectionBase):
def default_body(self):
return b"""
<DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2014-02-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<snapshotSet>
<item>
<snapshotId>snap-1a2b3c4d</snapshotId>
@@ -1589,9 +1596,9 @@ class TestDescribeSnapshots(TestEC2ConnectionBase):
'Action': 'DescribeSnapshots',
'SnapshotId.1': 'snap-1a2b3c4d',
'SnapshotId.2': 'snap-5e6f7a8b'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
self.assertEqual(len(result), 2)
self.assertEqual(result[0].id, 'snap-1a2b3c4d')
self.assertTrue(result[0].encrypted)
@@ -1603,7 +1610,7 @@ class TestCreateVolume(TestEC2ConnectionBase):
def default_body(self):
return b"""
<CreateVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2014-05-01/">
- <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
+ <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
<volumeId>vol-1a2b3c4d</volumeId>
<size>80</size>
<snapshotId/>
@@ -1625,9 +1632,9 @@ class TestCreateVolume(TestEC2ConnectionBase):
'Size': 80,
'SnapshotId': 'snap-1a2b3c4d',
'Encrypted': 'true'},
- ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
- 'SignatureVersion', 'Timestamp',
- 'Version'])
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
self.assertEqual(result.id, 'vol-1a2b3c4d')
self.assertTrue(result.encrypted)
diff --git a/tests/unit/ec2/test_ec2object.py b/tests/unit/ec2/test_ec2object.py
index 9b57df5f..14841e91 100644
--- a/tests/unit/ec2/test_ec2object.py
+++ b/tests/unit/ec2/test_ec2object.py
@@ -47,8 +47,8 @@ class TestAddTags(AWSMockServiceTestCase):
'Version'])
self.assertEqual(taggedEC2Object.tags, {
- "already_present_key":"already_present_value",
- "new_key":"new_value"})
+ "already_present_key": "already_present_value",
+ "new_key": "new_value"})
def test_add_tags(self):
self.set_http_response(status_code=200)
@@ -56,7 +56,7 @@ class TestAddTags(AWSMockServiceTestCase):
taggedEC2Object.id = "i-abcd1234"
taggedEC2Object.tags["already_present_key"] = "already_present_value"
- taggedEC2Object.add_tags({"key1":"value1", "key2":"value2"})
+ taggedEC2Object.add_tags({"key1": "value1", "key2": "value2"})
self.assert_request_parameters({
'ResourceId.1': 'i-abcd1234',
@@ -70,8 +70,8 @@ class TestAddTags(AWSMockServiceTestCase):
'Version'])
self.assertEqual(taggedEC2Object.tags, {
- "already_present_key":"already_present_value",
- "key1":"value1",
+ "already_present_key": "already_present_value",
+ "key1": "value1",
"key2": "value2"})
@@ -99,7 +99,7 @@ class TestRemoveTags(AWSMockServiceTestCase):
'SignatureVersion', 'Timestamp',
'Version'])
- self.assertEqual(taggedEC2Object.tags, {"key2":"value2"})
+ self.assertEqual(taggedEC2Object.tags, {"key2": "value2"})
def test_remove_tag_no_value(self):
self.set_http_response(status_code=200)
@@ -118,7 +118,7 @@ class TestRemoveTags(AWSMockServiceTestCase):
'SignatureVersion', 'Timestamp',
'Version'])
- self.assertEqual(taggedEC2Object.tags, {"key2":"value2"})
+ self.assertEqual(taggedEC2Object.tags, {"key2": "value2"})
def test_remove_tag_empty_value(self):
self.set_http_response(status_code=200)
@@ -138,7 +138,73 @@ class TestRemoveTags(AWSMockServiceTestCase):
'SignatureVersion', 'Timestamp',
'Version'])
- self.assertEqual(taggedEC2Object.tags, {"key2":"value2"})
+ self.assertEqual(taggedEC2Object.tags,
+ {"key1": "value1", "key2": "value2"})
+
+ def test_remove_tags(self):
+ self.set_http_response(status_code=200)
+ taggedEC2Object = TaggedEC2Object(self.service_connection)
+ taggedEC2Object.id = "i-abcd1234"
+ taggedEC2Object.tags["key1"] = "value1"
+ taggedEC2Object.tags["key2"] = "value2"
+
+ taggedEC2Object.remove_tags({"key1": "value1", "key2": "value2"})
+
+ self.assert_request_parameters({
+ 'ResourceId.1': 'i-abcd1234',
+ 'Action': 'DeleteTags',
+ 'Tag.1.Key': 'key1',
+ 'Tag.1.Value': 'value1',
+ 'Tag.2.Key': 'key2',
+ 'Tag.2.Value': 'value2'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
+ self.assertEqual(taggedEC2Object.tags, {})
+
+ def test_remove_tags_wrong_values(self):
+ self.set_http_response(status_code=200)
+ taggedEC2Object = TaggedEC2Object(self.service_connection)
+ taggedEC2Object.id = "i-abcd1234"
+ taggedEC2Object.tags["key1"] = "value1"
+ taggedEC2Object.tags["key2"] = "value2"
+
+ taggedEC2Object.remove_tags({"key1": "value1", "key2": "value3"})
+
+ self.assert_request_parameters({
+ 'ResourceId.1': 'i-abcd1234',
+ 'Action': 'DeleteTags',
+ 'Tag.1.Key': 'key1',
+ 'Tag.1.Value': 'value1',
+ 'Tag.2.Key': 'key2',
+ 'Tag.2.Value': 'value3'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
+ self.assertEqual(taggedEC2Object.tags, {"key2": "value2"})
+
+ def test_remove_tags_none_values(self):
+ self.set_http_response(status_code=200)
+ taggedEC2Object = TaggedEC2Object(self.service_connection)
+ taggedEC2Object.id = "i-abcd1234"
+ taggedEC2Object.tags["key1"] = "value1"
+ taggedEC2Object.tags["key2"] = "value2"
+
+ taggedEC2Object.remove_tags({"key1": "value1", "key2": None})
+
+ self.assert_request_parameters({
+ 'ResourceId.1': 'i-abcd1234',
+ 'Action': 'DeleteTags',
+ 'Tag.1.Key': 'key1',
+ 'Tag.1.Value': 'value1',
+ 'Tag.2.Key': 'key2'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
+ self.assertEqual(taggedEC2Object.tags, {})
if __name__ == '__main__':
diff --git a/tests/unit/ec2/test_instance.py b/tests/unit/ec2/test_instance.py
index 910337e8..4794d4cc 100644
--- a/tests/unit/ec2/test_instance.py
+++ b/tests/unit/ec2/test_instance.py
@@ -5,7 +5,6 @@ from tests.compat import unittest, mock
from tests.unit import AWSMockServiceTestCase
from boto.ec2.connection import EC2Connection
-from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
DESCRIBE_INSTANCE_VPC = br"""<?xml version="1.0" encoding="UTF-8"?>
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2012-10-01/">
@@ -224,7 +223,7 @@ class TestRunInstances(AWSMockServiceTestCase):
image_id='123456',
instance_type='m1.large',
security_groups=['group1', 'group2'],
- user_data = '#!/bin/bash'
+ user_data='#!/bin/bash'
)
self.assert_request_parameters({
diff --git a/tests/unit/ec2/test_instancestatus.py b/tests/unit/ec2/test_instancestatus.py
index 701b2720..38224d7d 100644
--- a/tests/unit/ec2/test_instancestatus.py
+++ b/tests/unit/ec2/test_instancestatus.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
from tests.compat import mock, unittest
-from tests.unit import AWSMockServiceTestCase
from boto.ec2.connection import EC2Connection
@@ -26,7 +25,6 @@ class TestInstanceStatusResponseParsing(unittest.TestCase):
self.assertNotIn('IncludeAllInstances', ec2.make_request.call_args[0][1])
self.assertEqual(all_statuses.next_token, 'page-2')
-
def test_include_all_instances(self):
ec2 = EC2Connection(aws_access_key_id='aws_access_key_id',
aws_secret_access_key='aws_secret_access_key')
diff --git a/tests/unit/ec2/test_instancetype.py b/tests/unit/ec2/test_instancetype.py
index dd81ca49..94e1e8fc 100644
--- a/tests/unit/ec2/test_instancetype.py
+++ b/tests/unit/ec2/test_instancetype.py
@@ -4,9 +4,9 @@ from tests.unit import AWSMockServiceTestCase
import boto.ec2
-from boto.ec2.instancetype import InstanceType
from boto.ec2.connection import EC2Connection
+
class TestEC2ConnectionBase(AWSMockServiceTestCase):
connection_class = EC2Connection
diff --git a/tests/unit/ec2/test_networkinterface.py b/tests/unit/ec2/test_networkinterface.py
index 9e23f72b..c872da0d 100644
--- a/tests/unit/ec2/test_networkinterface.py
+++ b/tests/unit/ec2/test_networkinterface.py
@@ -93,13 +93,13 @@ class NetworkInterfaceTests(unittest.TestCase):
self.eni_two.connection = mock.Mock()
self.eni_two.detach()
self.eni_two.connection.detach_network_interface.assert_called_with(
- None, False, dry_run=False)
+ None, False, dry_run=False)
def test_detach_with_force_calls_detach_network_interface_with_force(self):
self.eni_one.connection = mock.Mock()
self.eni_one.detach(True)
self.eni_one.connection.detach_network_interface.assert_called_with(
- 'eni-attach-1', True, dry_run=False)
+ 'eni-attach-1', True, dry_run=False)
class TestNetworkInterfaceCollection(unittest.TestCase):
diff --git a/tests/unit/ec2/test_securitygroup.py b/tests/unit/ec2/test_securitygroup.py
index e9601488..78c634cf 100644
--- a/tests/unit/ec2/test_securitygroup.py
+++ b/tests/unit/ec2/test_securitygroup.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-from tests.compat import mock, unittest
+from tests.compat import unittest
from tests.unit import AWSMockServiceTestCase
from boto.ec2.connection import EC2Connection
@@ -170,6 +170,7 @@ DESCRIBE_INSTANCES = br"""<?xml version="1.0" encoding="UTF-8"?>
</DescribeInstancesResponse>
"""
+
class TestDescribeSecurityGroups(AWSMockServiceTestCase):
connection_class = EC2Connection
diff --git a/tests/unit/ec2/test_spotinstance.py b/tests/unit/ec2/test_spotinstance.py
index 94f5bde6..b4c81caa 100644
--- a/tests/unit/ec2/test_spotinstance.py
+++ b/tests/unit/ec2/test_spotinstance.py
@@ -89,7 +89,7 @@ class TestGetSpotPriceHistory(AWSMockServiceTestCase):
self.assertEqual(response[0].availability_zone, 'us-west-2c')
self.assertEqual(response[1].instance_type, 'c3.large')
self.assertEqual(response[1].availability_zone, 'us-west-2b')
-
+
response = self.service_connection.get_spot_price_history(
filters={'instance-type': 'c3.large'})
self.assert_request_parameters({
@@ -99,7 +99,7 @@ class TestGetSpotPriceHistory(AWSMockServiceTestCase):
ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
'SignatureVersion', 'Timestamp',
'Version'])
-
+
response = self.service_connection.get_spot_price_history(
next_token='foobar')
self.assert_request_parameters({
diff --git a/tests/unit/ec2/test_volume.py b/tests/unit/ec2/test_volume.py
index a14ce6b3..81d7f552 100644
--- a/tests/unit/ec2/test_volume.py
+++ b/tests/unit/ec2/test_volume.py
@@ -144,20 +144,19 @@ class VolumeTests(unittest.TestCase):
self.volume_one.connection = mock.Mock()
self.volume_one.detach()
self.volume_one.connection.detach_volume.assert_called_with(
- 1, 2, "/dev/null", False, dry_run=False)
+ 1, 2, "/dev/null", False, dry_run=False)
def test_detach_with_no_attach_data(self):
self.volume_two.connection = mock.Mock()
self.volume_two.detach()
self.volume_two.connection.detach_volume.assert_called_with(
- 1, None, None, False, dry_run=False)
+ 1, None, None, False, dry_run=False)
def test_detach_with_force_calls_detach_volume_with_force(self):
self.volume_one.connection = mock.Mock()
self.volume_one.detach(True)
self.volume_one.connection.detach_volume.assert_called_with(
- 1, 2, "/dev/null", True, dry_run=False)
-
+ 1, 2, "/dev/null", True, dry_run=False)
def test_create_snapshot_calls_connection_create_snapshot(self):
self.volume_one.connection = mock.Mock()
@@ -205,7 +204,8 @@ class VolumeTests(unittest.TestCase):
self.volume_one.connection.get_all_snapshots.return_value = []
self.volume_one.snapshots("owner", "restorable_by")
self.volume_one.connection.get_all_snapshots.assert_called_with(
- owner="owner", restorable_by="restorable_by", dry_run=False)
+ owner="owner", restorable_by="restorable_by", dry_run=False)
+
class AttachmentSetTests(unittest.TestCase):
def check_that_attribute_has_been_set(self, name, value, attribute):
@@ -231,6 +231,7 @@ class AttachmentSetTests(unittest.TestCase):
def test_endElement_with_other_name_sets_other_name_attribute(self):
return self.check_that_attribute_has_been_set("someName", "some value", "someName")
+
class VolumeAttributeTests(unittest.TestCase):
def setUp(self):
self.volume_attribute = VolumeAttribute()