summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Yan <felixonmars@gmail.com>2014-07-30 19:37:24 +0800
committerFelix Yan <felixonmars@gmail.com>2014-07-30 19:37:24 +0800
commit4b8269562e663f090403e57ba1a3a471b6e0aa0e (patch)
tree24e33cac1cb6be5b480e4a60f814072d3dd4518b
parenta9e8057893cceefac8182e868b8d22f316039787 (diff)
downloadboto-4b8269562e663f090403e57ba1a3a471b6e0aa0e.tar.gz
ec2 module: tidy up to meet PEP8 better
-rw-r--r--boto/ec2/address.py3
-rw-r--r--boto/ec2/autoscale/__init__.py16
-rw-r--r--boto/ec2/autoscale/activity.py1
-rw-r--r--boto/ec2/autoscale/instance.py1
-rw-r--r--boto/ec2/autoscale/launchconfig.py1
-rw-r--r--boto/ec2/autoscale/limits.py4
-rw-r--r--boto/ec2/autoscale/policy.py7
-rw-r--r--boto/ec2/autoscale/request.py2
-rw-r--r--boto/ec2/autoscale/scheduled.py1
-rw-r--r--boto/ec2/bundleinstance.py2
-rw-r--r--boto/ec2/buyreservation.py8
-rw-r--r--boto/ec2/cloudwatch/__init__.py44
-rw-r--r--boto/ec2/cloudwatch/alarm.py17
-rw-r--r--boto/ec2/cloudwatch/datapoint.py1
-rw-r--r--boto/ec2/cloudwatch/dimension.py1
-rw-r--r--boto/ec2/cloudwatch/listelement.py3
-rw-r--r--boto/ec2/connection.py67
-rw-r--r--boto/ec2/ec2object.py5
-rw-r--r--boto/ec2/elb/attributes.py6
-rw-r--r--boto/ec2/elb/instancestate.py1
-rw-r--r--boto/ec2/elb/policies.py1
-rw-r--r--boto/ec2/elb/securitygroup.py2
-rw-r--r--boto/ec2/group.py2
-rw-r--r--boto/ec2/image.py5
-rw-r--r--boto/ec2/instanceinfo.py8
-rw-r--r--boto/ec2/instancetype.py2
-rw-r--r--boto/ec2/keypair.py4
-rw-r--r--boto/ec2/networkinterface.py11
-rw-r--r--boto/ec2/placementgroup.py3
-rw-r--r--boto/ec2/regioninfo.py1
-rw-r--r--boto/ec2/reservedinstance.py6
-rw-r--r--boto/ec2/securitygroup.py3
-rw-r--r--boto/ec2/snapshot.py3
-rw-r--r--boto/ec2/spotdatafeedsubscription.py4
-rw-r--r--boto/ec2/spotpricehistory.py3
-rw-r--r--boto/ec2/zone.py6
-rw-r--r--tests/integration/ec2/__init__.py2
-rw-r--r--tests/integration/ec2/autoscale/__init__.py1
-rw-r--r--tests/integration/ec2/cloudwatch/__init__.py2
-rw-r--r--tests/integration/ec2/cloudwatch/test_connection.py21
-rw-r--r--tests/integration/ec2/elb/__init__.py2
-rw-r--r--tests/integration/ec2/elb/test_connection.py4
-rwxr-xr-xtests/unit/ec2/autoscale/test_group.py52
-rw-r--r--tests/unit/ec2/elb/test_attribute.py10
-rw-r--r--tests/unit/ec2/elb/test_loadbalancer.py1
-rw-r--r--tests/unit/ec2/test_address.py3
-rw-r--r--tests/unit/ec2/test_blockdevicemapping.py3
-rwxr-xr-xtests/unit/ec2/test_connection.py189
-rw-r--r--tests/unit/ec2/test_ec2object.py16
-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
56 files changed, 301 insertions, 289 deletions
diff --git a/boto/ec2/address.py b/boto/ec2/address.py
index ce1189ed..5c1ec7eb 100644
--- a/boto/ec2/address.py
+++ b/boto/ec2/address.py
@@ -22,6 +22,7 @@
from boto.ec2.ec2object import EC2Object
+
class Address(EC2Object):
"""
Represents an EC2 Elastic IP Address
@@ -125,5 +126,3 @@ class Address(EC2Object):
self.public_ip,
dry_run=dry_run
)
-
-
diff --git a/boto/ec2/autoscale/__init__.py b/boto/ec2/autoscale/__init__.py
index fc0534b4..96c42848 100644
--- a/boto/ec2/autoscale/__init__.py
+++ b/boto/ec2/autoscale/__init__.py
@@ -105,14 +105,14 @@ class AutoScaleConnection(AWSQueryConnection):
self.region = region
self.use_block_device_types = use_block_device_types
super(AutoScaleConnection, self).__init__(aws_access_key_id,
- aws_secret_access_key,
- is_secure, port, proxy, proxy_port,
- proxy_user, proxy_pass,
- self.region.endpoint, debug,
- https_connection_factory, path=path,
- security_token=security_token,
- validate_certs=validate_certs,
- profile_name=profile_name)
+ aws_secret_access_key,
+ is_secure, port, proxy, proxy_port,
+ proxy_user, proxy_pass,
+ self.region.endpoint, debug,
+ https_connection_factory, path=path,
+ security_token=security_token,
+ validate_certs=validate_certs,
+ profile_name=profile_name)
def _required_auth_capability(self):
return ['hmac-v4']
diff --git a/boto/ec2/autoscale/activity.py b/boto/ec2/autoscale/activity.py
index 3f23d05d..bfe32f43 100644
--- a/boto/ec2/autoscale/activity.py
+++ b/boto/ec2/autoscale/activity.py
@@ -71,4 +71,3 @@ class Activity(object):
self.status_code = value
else:
setattr(self, name, value)
-
diff --git a/boto/ec2/autoscale/instance.py b/boto/ec2/autoscale/instance.py
index 6eb89c2c..6095c17b 100644
--- a/boto/ec2/autoscale/instance.py
+++ b/boto/ec2/autoscale/instance.py
@@ -57,4 +57,3 @@ class Instance(object):
self.group_name = value
else:
setattr(self, name, value)
-
diff --git a/boto/ec2/autoscale/launchconfig.py b/boto/ec2/autoscale/launchconfig.py
index a4e6ce9a..6d897fd2 100644
--- a/boto/ec2/autoscale/launchconfig.py
+++ b/boto/ec2/autoscale/launchconfig.py
@@ -20,7 +20,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-from datetime import datetime
from boto.ec2.elb.listelement import ListElement
# Namespacing issue with deprecated local class
from boto.ec2.blockdevicemapping import BlockDeviceMapping as BDM
diff --git a/boto/ec2/autoscale/limits.py b/boto/ec2/autoscale/limits.py
index 8472a201..89ece672 100644
--- a/boto/ec2/autoscale/limits.py
+++ b/boto/ec2/autoscale/limits.py
@@ -19,6 +19,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class AccountLimits(object):
def __init__(self, connection=None):
self.connection = connection
@@ -27,7 +28,7 @@ class AccountLimits(object):
def __repr__(self):
return 'AccountLimits: [%s, %s]' % (self.max_autoscaling_groups,
- self.max_launch_configurations)
+ self.max_launch_configurations)
def startElement(self, name, attrs, connection):
return None
@@ -41,4 +42,3 @@ class AccountLimits(object):
self.max_launch_configurations = int(value)
else:
setattr(self, name, value)
-
diff --git a/boto/ec2/autoscale/policy.py b/boto/ec2/autoscale/policy.py
index fbe7dc5f..191ac496 100644
--- a/boto/ec2/autoscale/policy.py
+++ b/boto/ec2/autoscale/policy.py
@@ -23,6 +23,7 @@
from boto.resultset import ResultSet
from boto.ec2.elb.listelement import ListElement
+
class Alarm(object):
def __init__(self, connection=None):
self.connection = connection
@@ -64,18 +65,24 @@ class AdjustmentType(object):
class MetricCollectionTypes(object):
class BaseType(object):
arg = ''
+
def __init__(self, connection):
self.connection = connection
self.val = None
+
def __repr__(self):
return '%s:%s' % (self.arg, self.val)
+
def startElement(self, name, attrs, connection):
return
+
def endElement(self, name, value, connection):
if name == self.arg:
self.val = value
+
class Metric(BaseType):
arg = 'Metric'
+
class Granularity(BaseType):
arg = 'Granularity'
diff --git a/boto/ec2/autoscale/request.py b/boto/ec2/autoscale/request.py
index c066dff5..b17b534f 100644
--- a/boto/ec2/autoscale/request.py
+++ b/boto/ec2/autoscale/request.py
@@ -19,6 +19,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class Request(object):
def __init__(self, connection=None):
self.connection = connection
@@ -35,4 +36,3 @@ class Request(object):
self.request_id = value
else:
setattr(self, name, value)
-
diff --git a/boto/ec2/autoscale/scheduled.py b/boto/ec2/autoscale/scheduled.py
index 8e307c20..8d2eda40 100644
--- a/boto/ec2/autoscale/scheduled.py
+++ b/boto/ec2/autoscale/scheduled.py
@@ -75,4 +75,3 @@ class ScheduledUpdateGroupAction(object):
self.end_time = datetime.strptime(value, '%Y-%m-%dT%H:%M:%SZ')
else:
setattr(self, name, value)
-
diff --git a/boto/ec2/bundleinstance.py b/boto/ec2/bundleinstance.py
index 1bb4dd16..e241da9a 100644
--- a/boto/ec2/bundleinstance.py
+++ b/boto/ec2/bundleinstance.py
@@ -25,6 +25,7 @@ Represents an EC2 Bundle Task
from boto.ec2.ec2object import EC2Object
+
class BundleInstanceTask(EC2Object):
def __init__(self, connection=None):
@@ -75,4 +76,3 @@ class BundleInstanceTask(EC2Object):
self.message = value
else:
setattr(self, name, value)
-
diff --git a/boto/ec2/buyreservation.py b/boto/ec2/buyreservation.py
index 7a0e6751..786d0fed 100644
--- a/boto/ec2/buyreservation.py
+++ b/boto/ec2/buyreservation.py
@@ -14,19 +14,21 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
import boto.ec2
from boto.sdb.db.property import StringProperty, IntegerProperty
from boto.manage import propget
+from boto.compat import six
InstanceTypes = ['m1.small', 'm1.large', 'm1.xlarge',
'c1.medium', 'c1.xlarge', 'm2.xlarge',
'm2.2xlarge', 'm2.4xlarge', 'cc1.4xlarge',
't1.micro']
+
class BuyReservation(object):
def get_region(self, params):
@@ -51,7 +53,7 @@ class BuyReservation(object):
prop = StringProperty(name='zone', verbose_name='EC2 Availability Zone',
choices=self.ec2.get_all_zones)
params['zone'] = propget.get(prop)
-
+
def get(self, params):
self.get_region(params)
self.ec2 = params['region'].connect()
@@ -76,7 +78,7 @@ if __name__ == "__main__":
unit_price = float(offering.fixed_price)
total_price = unit_price * params['quantity']
print('!!! You are about to purchase %d of these offerings for a total of $%.2f !!!' % (params['quantity'], total_price))
- answer = raw_input('Are you sure you want to do this? If so, enter YES: ')
+ answer = six.moves.input('Are you sure you want to do this? If so, enter YES: ')
if answer.strip().lower() == 'yes':
offering.purchase(params['quantity'])
else:
diff --git a/boto/ec2/cloudwatch/__init__.py b/boto/ec2/cloudwatch/__init__.py
index 0c9115e8..9b150b4e 100644
--- a/boto/ec2/cloudwatch/__init__.py
+++ b/boto/ec2/cloudwatch/__init__.py
@@ -92,14 +92,14 @@ class CloudWatchConnection(AWSQueryConnection):
validate_certs = False
super(CloudWatchConnection, self).__init__(aws_access_key_id,
- aws_secret_access_key,
- is_secure, port, proxy, proxy_port,
- proxy_user, proxy_pass,
- self.region.endpoint, debug,
- https_connection_factory, path,
- security_token,
- validate_certs=validate_certs,
- profile_name=profile_name)
+ aws_secret_access_key,
+ is_secure, port, proxy, proxy_port,
+ proxy_user, proxy_pass,
+ self.region.endpoint, debug,
+ https_connection_factory, path,
+ security_token,
+ validate_certs=validate_certs,
+ profile_name=profile_name)
def _required_auth_capability(self):
return ['hmac-v4']
@@ -113,11 +113,11 @@ class CloudWatchConnection(AWSQueryConnection):
if isinstance(dim_value, six.string_types):
dim_value = [dim_value]
for value in dim_value:
- params['%s.%d.Name' % (prefix, i+1)] = dim_name
- params['%s.%d.Value' % (prefix, i+1)] = value
+ params['%s.%d.Name' % (prefix, i + 1)] = dim_name
+ params['%s.%d.Value' % (prefix, i + 1)] = value
i += 1
else:
- params['%s.%d.Name' % (prefix, i+1)] = dim_name
+ params['%s.%d.Name' % (prefix, i + 1)] = dim_name
i += 1
def build_list_params(self, params, items, label):
@@ -134,7 +134,7 @@ class CloudWatchConnection(AWSQueryConnection):
params[label % i] = item
def build_put_params(self, params, name, value=None, timestamp=None,
- unit=None, dimensions=None, statistics=None):
+ unit=None, dimensions=None, statistics=None):
args = (name, value, unit, dimensions, statistics, timestamp)
length = max(map(lambda a: len(a) if isinstance(a, list) else 1, args))
@@ -329,7 +329,7 @@ class CloudWatchConnection(AWSQueryConnection):
"""
params = {'Namespace': namespace}
self.build_put_params(params, name, value=value, timestamp=timestamp,
- unit=unit, dimensions=dimensions, statistics=statistics)
+ unit=unit, dimensions=dimensions, statistics=statistics)
return self.get_status('PutMetricData', params, verb="POST")
@@ -498,15 +498,15 @@ class CloudWatchConnection(AWSQueryConnection):
:param alarm: MetricAlarm object.
"""
params = {
- 'AlarmName': alarm.name,
- 'MetricName': alarm.metric,
- 'Namespace': alarm.namespace,
- 'Statistic': alarm.statistic,
- 'ComparisonOperator': alarm.comparison,
- 'Threshold': alarm.threshold,
- 'EvaluationPeriods': alarm.evaluation_periods,
- 'Period': alarm.period,
- }
+ 'AlarmName': alarm.name,
+ 'MetricName': alarm.metric,
+ 'Namespace': alarm.namespace,
+ 'Statistic': alarm.statistic,
+ 'ComparisonOperator': alarm.comparison,
+ 'Threshold': alarm.threshold,
+ 'EvaluationPeriods': alarm.evaluation_periods,
+ 'Period': alarm.period,
+ }
if alarm.actions_enabled is not None:
params['ActionsEnabled'] = alarm.actions_enabled
if alarm.alarm_actions:
diff --git a/boto/ec2/cloudwatch/alarm.py b/boto/ec2/cloudwatch/alarm.py
index 4989fb34..ac6de3d2 100644
--- a/boto/ec2/cloudwatch/alarm.py
+++ b/boto/ec2/cloudwatch/alarm.py
@@ -52,11 +52,11 @@ class MetricAlarm(object):
INSUFFICIENT_DATA = 'INSUFFICIENT_DATA'
_cmp_map = {
- '>=': 'GreaterThanOrEqualToThreshold',
- '>': 'GreaterThanThreshold',
- '<': 'LessThanThreshold',
- '<=': 'LessThanOrEqualToThreshold',
- }
+ '>=': 'GreaterThanOrEqualToThreshold',
+ '>': 'GreaterThanThreshold',
+ '<': 'LessThanThreshold',
+ '<=': 'LessThanOrEqualToThreshold',
+ }
_rev_cmp_map = dict((v, k) for (k, v) in six.iteritems(_cmp_map))
def __init__(self, connection=None, name=None, metric=None,
@@ -122,15 +122,15 @@ class MetricAlarm(object):
'InstanceId': ['i-0123456', 'i-0123457'],
'LoadBalancerName': 'test-lb'
}
-
+
:type alarm_actions: list of strs
:param alarm_actions: A list of the ARNs of the actions to take in
ALARM state
-
+
:type insufficient_data_actions: list of strs
:param insufficient_data_actions: A list of the ARNs of the actions to
take in INSUFFICIENT_DATA state
-
+
:type ok_actions: list of strs
:param ok_actions: A list of the ARNs of the actions to take in OK state
"""
@@ -295,6 +295,7 @@ class MetricAlarm(object):
def delete(self):
self.connection.delete_alarms([self.name])
+
class AlarmHistoryItem(object):
def __init__(self, connection=None):
self.connection = connection
diff --git a/boto/ec2/cloudwatch/datapoint.py b/boto/ec2/cloudwatch/datapoint.py
index a33771a1..94955acd 100644
--- a/boto/ec2/cloudwatch/datapoint.py
+++ b/boto/ec2/cloudwatch/datapoint.py
@@ -21,6 +21,7 @@
#
from datetime import datetime
+
class Datapoint(dict):
def __init__(self, connection=None):
diff --git a/boto/ec2/cloudwatch/dimension.py b/boto/ec2/cloudwatch/dimension.py
index 86ebb9c3..9ff4fb11 100644
--- a/boto/ec2/cloudwatch/dimension.py
+++ b/boto/ec2/cloudwatch/dimension.py
@@ -20,6 +20,7 @@
# IN THE SOFTWARE.
#
+
class Dimension(dict):
def startElement(self, name, attrs, connection):
diff --git a/boto/ec2/cloudwatch/listelement.py b/boto/ec2/cloudwatch/listelement.py
index 2dd9cef0..6a290418 100644
--- a/boto/ec2/cloudwatch/listelement.py
+++ b/boto/ec2/cloudwatch/listelement.py
@@ -14,11 +14,12 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class ListElement(list):
def startElement(self, name, attrs, connection):
diff --git a/boto/ec2/connection.py b/boto/ec2/connection.py
index e8d27652..3b482a58 100644
--- a/boto/ec2/connection.py
+++ b/boto/ec2/connection.py
@@ -93,14 +93,14 @@ class EC2Connection(AWSQueryConnection):
self.DefaultRegionEndpoint)
self.region = region
super(EC2Connection, self).__init__(aws_access_key_id,
- aws_secret_access_key,
- is_secure, port, proxy, proxy_port,
- proxy_user, proxy_pass,
- self.region.endpoint, debug,
- https_connection_factory, path,
- security_token,
- validate_certs=validate_certs,
- profile_name=profile_name)
+ aws_secret_access_key,
+ is_secure, port, proxy, proxy_port,
+ proxy_user, proxy_pass,
+ self.region.endpoint, debug,
+ https_connection_factory, path,
+ security_token,
+ validate_certs=validate_certs,
+ profile_name=profile_name)
if api_version:
self.APIVersion = api_version
@@ -270,7 +270,7 @@ class EC2Connection(AWSQueryConnection):
root_device_name=None, block_device_map=None,
dry_run=False, virtualization_type=None,
sriov_net_support=None,
- snapshot_id=None,
+ snapshot_id=None,
delete_root_volume_on_termination=False):
"""
Register an image.
@@ -323,7 +323,7 @@ class EC2Connection(AWSQueryConnection):
:type delete_root_volume_on_termination: bool
:param delete_root_volume_on_termination: Whether to delete the root
volume of the image after instance termination. Only applies when
- creating image from snapshot_id. Defaults to False. Note that
+ creating image from snapshot_id. Defaults to False. Note that
leaving volumes behind after instance termination is not free.
:rtype: string
@@ -345,8 +345,8 @@ class EC2Connection(AWSQueryConnection):
if root_device_name:
params['RootDeviceName'] = root_device_name
if snapshot_id:
- root_vol = BlockDeviceType(snapshot_id=snapshot_id,
- delete_on_termination=delete_root_volume_on_termination)
+ root_vol = BlockDeviceType(snapshot_id=snapshot_id,
+ delete_on_termination=delete_root_volume_on_termination)
block_device_map = BlockDeviceMapping()
block_device_map[root_device_name] = root_vol
if block_device_map:
@@ -358,7 +358,6 @@ class EC2Connection(AWSQueryConnection):
if sriov_net_support:
params['SriovNetSupport'] = sriov_net_support
-
rs = self.get_object('RegisterImage', params, ResultSet, verb='POST')
image_id = getattr(rs, 'imageId', None)
return image_id
@@ -1881,9 +1880,9 @@ class EC2Connection(AWSQueryConnection):
return self.get_status('AssignPrivateIpAddresses', params, verb='POST')
def _associate_address(self, status, instance_id=None, public_ip=None,
- allocation_id=None, network_interface_id=None,
- private_ip_address=None, allow_reassociation=False,
- dry_run=False):
+ allocation_id=None, network_interface_id=None,
+ private_ip_address=None, allow_reassociation=False,
+ dry_run=False):
params = {}
if instance_id is not None:
params['InstanceId'] = instance_id
@@ -1960,9 +1959,9 @@ class EC2Connection(AWSQueryConnection):
allow_reassociation=allow_reassociation, dry_run=dry_run)
def associate_address_object(self, instance_id=None, public_ip=None,
- allocation_id=None, network_interface_id=None,
- private_ip_address=None, allow_reassociation=False,
- dry_run=False):
+ allocation_id=None, network_interface_id=None,
+ private_ip_address=None, allow_reassociation=False,
+ dry_run=False):
"""
Associate an Elastic IP address with a currently running instance.
This requires one of ``public_ip`` or ``allocation_id`` depending
@@ -2589,7 +2588,7 @@ class EC2Connection(AWSQueryConnection):
now = datetime.utcnow()
last_hour = datetime(now.year, now.month, now.day, now.hour)
last_midnight = datetime(now.year, now.month, now.day)
- last_sunday = datetime(now.year, now.month, now.day) - timedelta(days = (now.weekday() + 1) % 7)
+ last_sunday = datetime(now.year, now.month, now.day) - timedelta(days=(now.weekday() + 1) % 7)
start_of_month = datetime(now.year, now.month, 1)
target_backup_times = []
@@ -2598,15 +2597,15 @@ class EC2Connection(AWSQueryConnection):
oldest_snapshot_date = datetime(2007, 1, 1)
for hour in range(0, hourly_backups):
- target_backup_times.append(last_hour - timedelta(hours = hour))
+ target_backup_times.append(last_hour - timedelta(hours=hour))
for day in range(0, daily_backups):
- target_backup_times.append(last_midnight - timedelta(days = day))
+ target_backup_times.append(last_midnight - timedelta(days=day))
for week in range(0, weekly_backups):
- target_backup_times.append(last_sunday - timedelta(weeks = week))
+ target_backup_times.append(last_sunday - timedelta(weeks=week))
- one_day = timedelta(days = 1)
+ one_day = timedelta(days=1)
monthly_snapshots_added = 0
while (start_of_month > oldest_snapshot_date and
(monthly_backups is True or
@@ -3080,7 +3079,7 @@ class EC2Connection(AWSQueryConnection):
:rtype: bool
:return: True if successful.
"""
- params = {'GroupName':group_name}
+ params = {'GroupName': group_name}
if src_security_group_name:
params['SourceSecurityGroupName'] = src_security_group_name
if src_security_group_owner_id:
@@ -3184,7 +3183,7 @@ class EC2Connection(AWSQueryConnection):
if not isinstance(cidr_ip, list):
cidr_ip = [cidr_ip]
for i, single_cidr_ip in enumerate(cidr_ip):
- params['IpPermissions.1.IpRanges.%d.CidrIp' % (i+1)] = \
+ params['IpPermissions.1.IpRanges.%d.CidrIp' % (i + 1)] = \
single_cidr_ip
if dry_run:
params['DryRun'] = 'true'
@@ -3278,7 +3277,7 @@ class EC2Connection(AWSQueryConnection):
:rtype: bool
:return: True if successful.
"""
- params = {'GroupName':group_name}
+ params = {'GroupName': group_name}
if src_security_group_name:
params['SourceSecurityGroupName'] = src_security_group_name
if src_security_group_owner_id:
@@ -3476,7 +3475,7 @@ class EC2Connection(AWSQueryConnection):
if dry_run:
params['DryRun'] = 'true'
regions = self.get_list('DescribeRegions', params,
- [('item', RegionInfo)], verb='POST')
+ [('item', RegionInfo)], verb='POST')
for region in regions:
region.connection_cls = EC2Connection
return regions
@@ -4110,7 +4109,7 @@ class EC2Connection(AWSQueryConnection):
:rtype: bool
:return: True if successful
"""
- params = {'GroupName':name, 'Strategy':strategy}
+ params = {'GroupName': name, 'Strategy': strategy}
if dry_run:
params['DryRun'] = 'true'
group = self.get_status('CreatePlacementGroup', params, verb='POST')
@@ -4127,7 +4126,7 @@ class EC2Connection(AWSQueryConnection):
:param dry_run: Set to True if the operation should not actually run.
"""
- params = {'GroupName':name}
+ params = {'GroupName': name}
if dry_run:
params['DryRun'] = 'true'
return self.get_status('DeletePlacementGroup', params, verb='POST')
@@ -4139,9 +4138,9 @@ class EC2Connection(AWSQueryConnection):
i = 1
for key in keys:
value = tags[key]
- params['Tag.%d.Key'%i] = key
+ params['Tag.%d.Key' % i] = key
if value is not None:
- params['Tag.%d.Value'%i] = value
+ params['Tag.%d.Value' % i] = value
i += 1
def get_all_tags(self, filters=None, dry_run=False, max_results=None):
@@ -4240,7 +4239,7 @@ class EC2Connection(AWSQueryConnection):
:type network_interface_ids: list
:param network_interface_ids: a list of strings representing ENI IDs
-
+
:type filters: dict
:param filters: Optional filters that can be used to limit
the results returned. Filters are provided
@@ -4408,7 +4407,7 @@ class EC2Connection(AWSQueryConnection):
if dry_run:
params['DryRun'] = 'true'
return self.get_object('CopyImage', params, CopyImage,
- verb='POST')
+ verb='POST')
def describe_account_attributes(self, attribute_names=None, dry_run=False):
"""
diff --git a/boto/ec2/ec2object.py b/boto/ec2/ec2object.py
index 383602e5..9edf12ee 100644
--- a/boto/ec2/ec2object.py
+++ b/boto/ec2/ec2object.py
@@ -25,6 +25,7 @@ Represents an EC2 Object
"""
from boto.ec2.tag import TagSet
+
class EC2Object(object):
def __init__(self, connection=None):
@@ -78,7 +79,7 @@ class TaggedEC2Object(EC2Object):
"""
status = self.connection.create_tags(
[self.id],
- {key : value},
+ {key: value},
dry_run=dry_run
)
if self.tags is None:
@@ -124,7 +125,7 @@ class TaggedEC2Object(EC2Object):
a value of '' and a value of None.
"""
if value is not None:
- tags = {key : value}
+ tags = {key: value}
else:
tags = [key]
status = self.connection.delete_tags(
diff --git a/boto/ec2/elb/attributes.py b/boto/ec2/elb/attributes.py
index 05ca8f82..20ed664b 100644
--- a/boto/ec2/elb/attributes.py
+++ b/boto/ec2/elb/attributes.py
@@ -19,6 +19,7 @@
#
# Created by Chris Huegle for TellApart, Inc.
+
class CrossZoneLoadBalancingAttribute(object):
"""
Represents the CrossZoneLoadBalancing segement of ELB Attributes.
@@ -40,6 +41,7 @@ class CrossZoneLoadBalancingAttribute(object):
else:
self.enabled = False
+
class AccessLogAttribute(object):
"""
Represents the AccessLog segment of ELB attributes.
@@ -74,6 +76,7 @@ class AccessLogAttribute(object):
elif name == 'EmitInterval':
self.emit_interval = int(value)
+
class ConnectionDrainingAttribute(object):
"""
Represents the ConnectionDraining segment of ELB attributes.
@@ -100,6 +103,7 @@ class ConnectionDrainingAttribute(object):
elif name == 'Timeout':
self.timeout = int(value)
+
class LbAttributes(object):
"""
Represents the Attributes of an Elastic Load Balancer.
@@ -107,7 +111,7 @@ class LbAttributes(object):
def __init__(self, connection=None):
self.connection = connection
self.cross_zone_load_balancing = CrossZoneLoadBalancingAttribute(
- self.connection)
+ self.connection)
self.access_log = AccessLogAttribute(self.connection)
self.connection_draining = ConnectionDrainingAttribute(self.connection)
diff --git a/boto/ec2/elb/instancestate.py b/boto/ec2/elb/instancestate.py
index 40f4cbe6..dd61c123 100644
--- a/boto/ec2/elb/instancestate.py
+++ b/boto/ec2/elb/instancestate.py
@@ -19,6 +19,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class InstanceState(object):
"""
Represents the state of an EC2 Load Balancer Instance
diff --git a/boto/ec2/elb/policies.py b/boto/ec2/elb/policies.py
index faea1c78..50fac0af 100644
--- a/boto/ec2/elb/policies.py
+++ b/boto/ec2/elb/policies.py
@@ -106,4 +106,3 @@ class Policies(object):
def endElement(self, name, value, connection):
return
-
diff --git a/boto/ec2/elb/securitygroup.py b/boto/ec2/elb/securitygroup.py
index 4f377907..65f981f8 100644
--- a/boto/ec2/elb/securitygroup.py
+++ b/boto/ec2/elb/securitygroup.py
@@ -19,6 +19,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class SecurityGroup(object):
def __init__(self, connection=None):
self.name = None
@@ -35,4 +36,3 @@ class SecurityGroup(object):
self.name = value
elif name == 'OwnerAlias':
self.owner_alias = value
-
diff --git a/boto/ec2/group.py b/boto/ec2/group.py
index fef54977..99d78734 100644
--- a/boto/ec2/group.py
+++ b/boto/ec2/group.py
@@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class Group(object):
def __init__(self, parent=None):
self.id = None
@@ -35,4 +36,3 @@ class Group(object):
self.name = value
else:
setattr(self, name, value)
-
diff --git a/boto/ec2/image.py b/boto/ec2/image.py
index f94f77e8..612404f0 100644
--- a/boto/ec2/image.py
+++ b/boto/ec2/image.py
@@ -41,6 +41,7 @@ class BillingProducts(list):
if name == 'billingProduct':
self.append(value)
+
class Image(TaggedEC2Object):
"""
Represents an EC2 Image
@@ -106,7 +107,7 @@ class Image(TaggedEC2Object):
self.is_public = True
else:
raise Exception(
- 'Unexpected value of isPublic %s for image %s'%(
+ 'Unexpected value of isPublic %s for image %s' % (
value,
self.id
)
@@ -368,7 +369,7 @@ class Image(TaggedEC2Object):
)
def get_kernel(self, dry_run=False):
- img_attrs =self.connection.get_image_attribute(
+ img_attrs = self.connection.get_image_attribute(
self.id,
'kernel',
dry_run=dry_run
diff --git a/boto/ec2/instanceinfo.py b/boto/ec2/instanceinfo.py
index 623ba17a..afa8b9cb 100644
--- a/boto/ec2/instanceinfo.py
+++ b/boto/ec2/instanceinfo.py
@@ -14,16 +14,17 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+
class InstanceInfo(object):
"""
Represents an EC2 Instance status response from CloudWatch
"""
-
+
def __init__(self, connection=None, id=None, state=None):
"""
:ivar str id: The instance's EC2 ID.
@@ -46,6 +47,3 @@ class InstanceInfo(object):
self.state = value
else:
setattr(self, name, value)
-
-
-
diff --git a/boto/ec2/instancetype.py b/boto/ec2/instancetype.py
index 2de4b853..6197a336 100644
--- a/boto/ec2/instancetype.py
+++ b/boto/ec2/instancetype.py
@@ -44,7 +44,7 @@ class InstanceType(EC2Object):
def __repr__(self):
return 'InstanceType:%s-%s,%s,%s' % (self.name, self.cores,
- self.memory, self.disk)
+ self.memory, self.disk)
def endElement(self, name, value, connection):
if name == 'name':
diff --git a/boto/ec2/keypair.py b/boto/ec2/keypair.py
index b399a97e..623fb409 100644
--- a/boto/ec2/keypair.py
+++ b/boto/ec2/keypair.py
@@ -27,6 +27,7 @@ import os
from boto.ec2.ec2object import EC2Object
from boto.exception import BotoClientError
+
class KeyPair(EC2Object):
def __init__(self, connection=None):
@@ -108,6 +109,3 @@ class KeyPair(EC2Object):
rconn = region.connect(**conn_params)
kp = rconn.create_key_pair(self.name, dry_run=dry_run)
return kp
-
-
-
diff --git a/boto/ec2/networkinterface.py b/boto/ec2/networkinterface.py
index 6596439e..9bbeb771 100644
--- a/boto/ec2/networkinterface.py
+++ b/boto/ec2/networkinterface.py
@@ -119,8 +119,7 @@ class NetworkInterface(TaggedEC2Object):
return 'NetworkInterface:%s' % self.id
def startElement(self, name, attrs, connection):
- retval = super(NetworkInterface, self).startElement(name, attrs,
- connection)
+ retval = super(NetworkInterface, self).startElement(name, attrs, connection)
if retval is not None:
return retval
if name == 'groupSet':
@@ -313,10 +312,10 @@ class NetworkInterfaceCollection(list):
if spec.associate_public_ip_address is not None:
if not params[full_prefix + 'DeviceIndex'] in (0, '0'):
raise BotoClientError(
- "Only the interface with device index of 0 can " + \
- "be provided when using " + \
- "'associate_public_ip_address'."
- )
+ "Only the interface with device index of 0 can " + \
+ "be provided when using " + \
+ "'associate_public_ip_address'."
+ )
if len(self) > 1:
raise BotoClientError(
diff --git a/boto/ec2/placementgroup.py b/boto/ec2/placementgroup.py
index 65e32844..0c259661 100644
--- a/boto/ec2/placementgroup.py
+++ b/boto/ec2/placementgroup.py
@@ -24,6 +24,7 @@ Represents an EC2 Placement Group
from boto.ec2.ec2object import EC2Object
from boto.exception import BotoClientError
+
class PlacementGroup(EC2Object):
def __init__(self, connection=None, name=None, strategy=None, state=None):
@@ -50,5 +51,3 @@ class PlacementGroup(EC2Object):
self.name,
dry_run=dry_run
)
-
-
diff --git a/boto/ec2/regioninfo.py b/boto/ec2/regioninfo.py
index 78cd757c..21a56fb9 100644
--- a/boto/ec2/regioninfo.py
+++ b/boto/ec2/regioninfo.py
@@ -23,6 +23,7 @@
from boto.regioninfo import RegionInfo
+
class EC2RegionInfo(RegionInfo):
"""
Represents an EC2 Region
diff --git a/boto/ec2/reservedinstance.py b/boto/ec2/reservedinstance.py
index 72d2bf30..02d15276 100644
--- a/boto/ec2/reservedinstance.py
+++ b/boto/ec2/reservedinstance.py
@@ -128,9 +128,9 @@ class ReservedInstance(ReservedInstancesOffering):
usage_price=None, description=None,
instance_count=None, state=None):
super(ReservedInstance, self).__init__(connection, id, instance_type,
- availability_zone, duration,
- fixed_price, usage_price,
- description)
+ availability_zone, duration,
+ fixed_price, usage_price,
+ description)
self.instance_count = instance_count
self.state = state
self.start = None
diff --git a/boto/ec2/securitygroup.py b/boto/ec2/securitygroup.py
index 5674f4e9..dec49cb2 100644
--- a/boto/ec2/securitygroup.py
+++ b/boto/ec2/securitygroup.py
@@ -44,8 +44,7 @@ class SecurityGroup(TaggedEC2Object):
return 'SecurityGroup:%s' % self.name
def startElement(self, name, attrs, connection):
- retval = super(SecurityGroup, self).startElement(name, attrs,
- connection)
+ retval = super(SecurityGroup, self).startElement(name, attrs, connection)
if retval is not None:
return retval
if name == 'ipPermissions':
diff --git a/boto/ec2/snapshot.py b/boto/ec2/snapshot.py
index 22f69ab2..8a84cdee 100644
--- a/boto/ec2/snapshot.py
+++ b/boto/ec2/snapshot.py
@@ -185,6 +185,3 @@ class SnapshotAttribute(object):
self.snapshot_id = value
else:
setattr(self, name, value)
-
-
-
diff --git a/boto/ec2/spotdatafeedsubscription.py b/boto/ec2/spotdatafeedsubscription.py
index 26ef7adc..d0e0be8d 100644
--- a/boto/ec2/spotdatafeedsubscription.py
+++ b/boto/ec2/spotdatafeedsubscription.py
@@ -25,10 +25,11 @@ Represents an EC2 Spot Instance Datafeed Subscription
from boto.ec2.ec2object import EC2Object
from boto.ec2.spotinstancerequest import SpotInstanceStateFault
+
class SpotDatafeedSubscription(EC2Object):
def __init__(self, connection=None, owner_id=None,
- bucket=None, prefix=None, state=None,fault=None):
+ bucket=None, prefix=None, state=None, fault=None):
super(SpotDatafeedSubscription, self).__init__(connection)
self.owner_id = owner_id
self.bucket = bucket
@@ -62,4 +63,3 @@ class SpotDatafeedSubscription(EC2Object):
return self.connection.delete_spot_datafeed_subscription(
dry_run=dry_run
)
-
diff --git a/boto/ec2/spotpricehistory.py b/boto/ec2/spotpricehistory.py
index 7bd0ce89..ac125de6 100644
--- a/boto/ec2/spotpricehistory.py
+++ b/boto/ec2/spotpricehistory.py
@@ -25,6 +25,7 @@ Represents an EC2 Spot Instance Request
from boto.ec2.ec2object import EC2Object
+
class SpotPriceHistory(EC2Object):
def __init__(self, connection=None):
@@ -51,5 +52,3 @@ class SpotPriceHistory(EC2Object):
self.availability_zone = value
else:
setattr(self, name, value)
-
-
diff --git a/boto/ec2/zone.py b/boto/ec2/zone.py
index 725d1769..85ed1022 100644
--- a/boto/ec2/zone.py
+++ b/boto/ec2/zone.py
@@ -24,6 +24,7 @@ Represents an EC2 Availability Zone
"""
from boto.ec2.ec2object import EC2Object
+
class MessageSet(list):
"""
A list object that contains messages associated with
@@ -39,6 +40,7 @@ class MessageSet(list):
else:
setattr(self, name, value)
+
class Zone(EC2Object):
"""
Represents an Availability Zone.
@@ -74,7 +76,3 @@ class Zone(EC2Object):
self.region_name = value
else:
setattr(self, name, value)
-
-
-
-
diff --git a/tests/integration/ec2/__init__.py b/tests/integration/ec2/__init__.py
index b3fc3a0c..771ca94b 100644
--- a/tests/integration/ec2/__init__.py
+++ b/tests/integration/ec2/__init__.py
@@ -14,7 +14,7 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
diff --git a/tests/integration/ec2/autoscale/__init__.py b/tests/integration/ec2/autoscale/__init__.py
index 4a55c4b7..53b3484c 100644
--- a/tests/integration/ec2/autoscale/__init__.py
+++ b/tests/integration/ec2/autoscale/__init__.py
@@ -18,4 +18,3 @@
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
-
diff --git a/tests/integration/ec2/cloudwatch/__init__.py b/tests/integration/ec2/cloudwatch/__init__.py
index b3fc3a0c..771ca94b 100644
--- a/tests/integration/ec2/cloudwatch/__init__.py
+++ b/tests/integration/ec2/cloudwatch/__init__.py
@@ -14,7 +14,7 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
diff --git a/tests/integration/ec2/cloudwatch/test_connection.py b/tests/integration/ec2/cloudwatch/test_connection.py
index 52a08b2d..a03e7f34 100644
--- a/tests/integration/ec2/cloudwatch/test_connection.py
+++ b/tests/integration/ec2/cloudwatch/test_connection.py
@@ -110,7 +110,7 @@ class CloudWatchConnectionTest(unittest.TestCase):
'ThingName1': 'thing1',
'ThingName2': 'thing2',
'ThingName3': 'thing3'
- }
+ }
self.assertEqual(params, expected_params)
def test_build_put_params_one(self):
@@ -122,7 +122,7 @@ class CloudWatchConnectionTest(unittest.TestCase):
'MetricData.member.1.Value': 1,
'MetricData.member.1.Dimensions.member.1.Name': 'D',
'MetricData.member.1.Dimensions.member.1.Value': 'V',
- }
+ }
self.assertEqual(params, expected_params)
def test_build_put_params_multiple_metrics(self):
@@ -138,7 +138,7 @@ class CloudWatchConnectionTest(unittest.TestCase):
'MetricData.member.2.Value': 2,
'MetricData.member.2.Dimensions.member.1.Name': 'D',
'MetricData.member.2.Dimensions.member.1.Value': 'V',
- }
+ }
self.assertEqual(params, expected_params)
def test_build_put_params_multiple_dimensions(self):
@@ -154,7 +154,7 @@ class CloudWatchConnectionTest(unittest.TestCase):
'MetricData.member.2.Value': 2,
'MetricData.member.2.Dimensions.member.1.Name': 'D',
'MetricData.member.2.Dimensions.member.1.Value': 'W',
- }
+ }
self.assertEqual(params, expected_params)
def test_build_put_params_multiple_parameter_dimension(self):
@@ -173,7 +173,7 @@ class CloudWatchConnectionTest(unittest.TestCase):
'MetricData.member.1.Dimensions.member.1.Value': 'V',
'MetricData.member.1.Dimensions.member.2.Name': 'D2',
'MetricData.member.1.Dimensions.member.2.Value': 'W',
- }
+ }
self.assertEqual(params, expected_params)
def test_build_get_params_multiple_parameter_dimension1(self):
@@ -187,7 +187,7 @@ class CloudWatchConnectionTest(unittest.TestCase):
'Dimensions.member.1.Value': 'V',
'Dimensions.member.2.Name': 'D2',
'Dimensions.member.2.Value': 'W',
- }
+ }
self.assertEqual(params, expected_params)
def test_build_get_params_multiple_parameter_dimension2(self):
@@ -204,7 +204,7 @@ class CloudWatchConnectionTest(unittest.TestCase):
'Dimensions.member.3.Name': 'D2',
'Dimensions.member.3.Value': 'W',
'Dimensions.member.4.Name': 'D3',
- }
+ }
self.assertEqual(params, expected_params)
def test_build_put_params_invalid(self):
@@ -221,9 +221,9 @@ class CloudWatchConnectionTest(unittest.TestCase):
c = CloudWatchConnection()
m = c.list_metrics()[0]
end = datetime.datetime.utcnow()
- start = end - datetime.timedelta(hours=24*14)
+ start = end - datetime.timedelta(hours=24 * 14)
c.get_metric_statistics(
- 3600*24, start, end, m.name, m.namespace, ['Average', 'Sum'])
+ 3600 * 24, start, end, m.name, m.namespace, ['Average', 'Sum'])
def test_put_metric_data(self):
c = CloudWatchConnection()
@@ -247,13 +247,14 @@ class CloudWatchConnectionTest(unittest.TestCase):
# self.assertEqual(row['Unit'], 'Bytes')
# self.assertEqual(row['Average'], 5.0)
-
def test_describe_alarms(self):
c = CloudWatchConnection()
+
def make_request(*args, **kwargs):
class Body(object):
def __init__(self):
self.status = 200
+
def read(self):
return DESCRIBE_ALARMS_BODY
return Body()
diff --git a/tests/integration/ec2/elb/__init__.py b/tests/integration/ec2/elb/__init__.py
index b3fc3a0c..771ca94b 100644
--- a/tests/integration/ec2/elb/__init__.py
+++ b/tests/integration/ec2/elb/__init__.py
@@ -14,7 +14,7 @@
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
-# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
diff --git a/tests/integration/ec2/elb/test_connection.py b/tests/integration/ec2/elb/test_connection.py
index 5464a405..5dc44141 100644
--- a/tests/integration/ec2/elb/test_connection.py
+++ b/tests/integration/ec2/elb/test_connection.py
@@ -69,7 +69,7 @@ class ELBConnectionTest(unittest.TestCase):
'ThingName1': 'thing1',
'ThingName2': 'thing2',
'ThingName3': 'thing3'
- }
+ }
self.assertEqual(params, expected_params)
# TODO: for these next tests, consider sleeping until our load
@@ -93,7 +93,7 @@ class ELBConnectionTest(unittest.TestCase):
self.assertEqual(
sorted(l.get_tuple() for l in balancers[0].listeners),
sorted(self.listeners + more_listeners)
- )
+ )
def test_delete_load_balancer_listeners(self):
mod_listeners = [(80, 8000, 'HTTP'), (443, 8001, 'HTTP')]
diff --git a/tests/unit/ec2/autoscale/test_group.py b/tests/unit/ec2/autoscale/test_group.py
index 73f2ccf8..19e2c7ca 100755
--- 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
@@ -353,19 +358,19 @@ class TestLaunchConfiguration(AWSMockServiceTestCase):
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', 'group2'],
+ 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)
@@ -386,7 +391,7 @@ class TestLaunchConfiguration(AWSMockServiceTestCase):
'SecurityGroups.member.1': 'group1',
'SecurityGroups.member.2': 'group2',
'SpotPrice': 'price',
- 'AssociatePublicIpAddress' : 'true',
+ 'AssociatePublicIpAddress': 'true',
'VolumeType': 'atype',
'DeleteOnTermination': 'false',
'Iops': 3000,
@@ -526,6 +531,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 +555,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 +563,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 +590,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 +617,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 +655,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 +683,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..3f00041f 100644
--- a/tests/unit/ec2/elb/test_attribute.py
+++ b/tests/unit/ec2/elb/test_attribute.py
@@ -63,7 +63,8 @@ ATTRIBUTE_TESTS = [
[('cross_zone_load_balancing.enabled', True)]),
(ATTRIBUTE_GET_FALSE_CZL_RESPONSE,
[('cross_zone_load_balancing.enabled', False)]),
- ]
+]
+
class TestLbAttributes(unittest.TestCase):
"""Tests LB Attributes."""
@@ -103,8 +104,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 +118,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 +151,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
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..5abbad0c 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,7 +22,6 @@ 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(
@@ -66,7 +66,6 @@ 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(
diff --git a/tests/unit/ec2/test_blockdevicemapping.py b/tests/unit/ec2/test_blockdevicemapping.py
index fa91fa3e..752b5596 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,7 @@ class BlockDeviceTypeTests(unittest.TestCase):
self.block_device_type.endElement("deleteOnTermination", 'something else', None)
self.assertEqual(self.block_device_type.delete_on_termination, False)
+
class BlockDeviceMappingTests(unittest.TestCase):
def setUp(self):
self.block_device_mapping = BlockDeviceMapping()
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..4ece8d92 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,7 @@ class TestRemoveTags(AWSMockServiceTestCase):
'SignatureVersion', 'Timestamp',
'Version'])
- self.assertEqual(taggedEC2Object.tags, {"key2":"value2"})
+ self.assertEqual(taggedEC2Object.tags, {"key2": "value2"})
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()