Skip to content

Commit

Permalink
autoscale module: add backward-compatible support for Python 3.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
felixonmars committed Jul 11, 2014
1 parent 317e322 commit 173c237
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ At the moment, boto supports:

* Amazon Elastic Compute Cloud (EC2)
* Amazon Elastic Map Reduce (EMR) (Python 3)
* AutoScaling
* AutoScaling (Python 3)
* Amazon Kinesis (Python 3)

* Content Delivery
Expand Down
2 changes: 1 addition & 1 deletion boto/ec2/autoscale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def build_list_params(self, params, items, label):
params['%s.member.%d.%s.%s' % (label, i, k, kk)] = vv
else:
params['%s.member.%d.%s' % (label, i, k)] = v
elif isinstance(items[i - 1], basestring):
elif isinstance(items[i - 1], six.string_types):
params['%s.member.%d' % (label, i)] = items[i - 1]

def _update_group(self, op, as_group):
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Currently Supported Services

* :doc:`Elastic Compute Cloud (EC2) <ec2_tut>` -- (:doc:`API Reference <ref/ec2>`)
* :doc:`Elastic MapReduce (EMR) <emr_tut>` -- (:doc:`API Reference <ref/emr>`) (Python 3)
* :doc:`Auto Scaling <autoscale_tut>` -- (:doc:`API Reference <ref/autoscale>`)
* :doc:`Auto Scaling <autoscale_tut>` -- (:doc:`API Reference <ref/autoscale>`) (Python 3)
* Kinesis -- (:doc:`API Reference <ref/kinesis>`) (Python 3)

* **Content Delivery**
Expand Down
7 changes: 4 additions & 3 deletions tests/integration/ec2/autoscale/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Some unit tests for the AutoscaleConnection
"""

import unittest
from __future__ import print_function
import time
from boto.ec2.autoscale import AutoScaleConnection
from boto.ec2.autoscale.activity import Activity
Expand All @@ -34,6 +34,7 @@
from boto.ec2.autoscale.scheduled import ScheduledUpdateGroupAction
from boto.ec2.autoscale.instance import Instance
from boto.ec2.autoscale.tag import Tag
from boto.compat import unittest


class AutoscaleConnectionTest(unittest.TestCase):
Expand All @@ -46,7 +47,7 @@ def test_basic(self):
# have any autoscale groups to introspect. It's useful, however, to
# catch simple errors

print '--- running %s tests ---' % self.__class__.__name__
print('--- running %s tests ---' % self.__class__.__name__)
c = AutoScaleConnection()

self.assertTrue(repr(c).startswith('AutoScaleConnection'))
Expand Down Expand Up @@ -164,7 +165,7 @@ def test_basic(self):

assert not found

print '--- tests completed ---'
print('--- tests completed ---')

def test_ebs_optimized_regression(self):
c = AutoScaleConnection()
Expand Down
1 change: 1 addition & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
'tests/unit/emr',
'tests/unit/glacier',
'tests/unit/iam',
'tests/unit/ec2/autoscale',
'tests/unit/ec2/elb',
'tests/unit/manage',
'tests/unit/provider',
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/ec2/autoscale/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setUp(self):
super(TestAutoScaleGroup, self).setUp()

def default_body(self):
return """
return b"""
<CreateLaunchConfigurationResponse>
<ResponseMetadata>
<RequestId>requestid</RequestId>
Expand Down Expand Up @@ -110,7 +110,7 @@ class TestAutoScaleGroupHonorCooldown(AWSMockServiceTestCase):
connection_class = AutoScaleConnection

def default_body(self):
return """
return b"""
<SetDesiredCapacityResponse>
<ResponseMetadata>
<RequestId>9fb7e2db-6998-11e2-a985-57c82EXAMPLE</RequestId>
Expand All @@ -135,7 +135,7 @@ def setUp(self):
super(TestScheduledGroup, self).setUp()

def default_body(self):
return """
return b"""
<PutScheduledUpdateGroupActionResponse>
<ResponseMetadata>
<RequestId>requestid</RequestId>
Expand Down Expand Up @@ -169,7 +169,7 @@ class TestParseAutoScaleGroupResponse(AWSMockServiceTestCase):
connection_class = AutoScaleConnection

def default_body(self):
return """
return b"""
<DescribeAutoScalingGroupsResult>
<AutoScalingGroups>
<member>
Expand Down Expand Up @@ -238,7 +238,7 @@ class TestDescribeTerminationPolicies(AWSMockServiceTestCase):
connection_class = AutoScaleConnection

def default_body(self):
return """
return b"""
<DescribeTerminationPolicyTypesResponse>
<DescribeTerminationPolicyTypesResult>
<TerminationPolicyTypes>
Expand Down Expand Up @@ -268,7 +268,7 @@ class TestLaunchConfigurationDescribe(AWSMockServiceTestCase):

def default_body(self):
# This is a dummy response
return """
return b"""
<DescribeLaunchConfigurationsResponse>
<DescribeLaunchConfigurationsResult>
<LaunchConfigurations>
Expand Down Expand Up @@ -336,7 +336,7 @@ class TestLaunchConfiguration(AWSMockServiceTestCase):

def default_body(self):
# This is a dummy response
return """
return b"""
<DescribeLaunchConfigurationsResponse>
</DescribeLaunchConfigurationsResponse>
"""
Expand Down Expand Up @@ -397,7 +397,7 @@ def setUp(self):
super(TestCreateAutoScalePolicy, self).setUp()

def default_body(self):
return """
return b"""
<PutScalingPolicyResponse xmlns="http://autoscaling.amazonaws.com\
/doc/2011-01-01/">
<PutScalingPolicyResult>
Expand Down Expand Up @@ -472,7 +472,7 @@ def setUp(self):
super(TestPutNotificationConfiguration, self).setUp()

def default_body(self):
return """
return b"""
<PutNotificationConfigurationResponse>
<ResponseMetadata>
<RequestId>requestid</RequestId>
Expand Down Expand Up @@ -502,7 +502,7 @@ def setUp(self):
super(TestDeleteNotificationConfiguration, self).setUp()

def default_body(self):
return """
return b"""
<DeleteNotificationConfigurationResponse>
<ResponseMetadata>
<RequestId>requestid</RequestId>
Expand All @@ -527,7 +527,7 @@ class TestAutoScalingTag(AWSMockServiceTestCase):
connection_class = AutoScaleConnection

def default_body(self):
return """
return b"""
<CreateOrUpdateTagsResponse>
<ResponseMetadata>
<RequestId>requestId</RequestId>
Expand Down Expand Up @@ -599,7 +599,7 @@ def setUp(self):
super(TestAttachInstances, self).setUp()

def default_body(self):
return """
return b"""
<AttachInstancesResponse>
<ResponseMetadata>
<RequestId>requestid</RequestId>
Expand Down Expand Up @@ -629,7 +629,7 @@ def setUp(self):
super(TestGetAccountLimits, self).setUp()

def default_body(self):
return """
return b"""
<DescribeAccountLimitsAnswer>
<MaxNumberOfAutoScalingGroups>6</MaxNumberOfAutoScalingGroups>
<MaxNumberOfLaunchConfigurations>3</MaxNumberOfLaunchConfigurations>
Expand All @@ -655,7 +655,7 @@ def setUp(self):
super(TestGetAdjustmentTypes, self).setUp()

def default_body(self):
return """
return b"""
<DescribeAdjustmentTypesResponse xmlns="http://autoscaling.amazonaws.com/doc/201-01-01/">
<DescribeAdjustmentTypesResult>
<AdjustmentTypes>
Expand Down Expand Up @@ -693,7 +693,7 @@ class TestLaunchConfigurationDescribeWithBlockDeviceTypes(AWSMockServiceTestCase

def default_body(self):
# This is a dummy response
return """
return b"""
<DescribeLaunchConfigurationsResponse>
<DescribeLaunchConfigurationsResult>
<LaunchConfigurations>
Expand Down

0 comments on commit 173c237

Please sign in to comment.