summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel G. Taylor <dan@programmer-art.org>2014-07-09 13:36:46 -0700
committerDaniel G. Taylor <dan@programmer-art.org>2014-07-09 13:36:46 -0700
commit15514f79581722c5f217b9ea781a7830a36de013 (patch)
tree53229f20036381e9d712f4b9107320909af53e95
parenta41042ef299a3f2c5d91a4e5db2bd570751824e5 (diff)
parentf400d90350b8e995e6337aec6b6a075881c0ba69 (diff)
downloadboto-15514f79581722c5f217b9ea781a7830a36de013.tar.gz
Merge pull request #2359 from felixonmars/route53-py3
route53 module: add backward-compatible support for Python 3.3+. Fixes #2359.
-rw-r--r--README.rst2
-rw-r--r--boto/route53/connection.py5
-rw-r--r--docs/source/index.rst2
-rw-r--r--tests/integration/route53/test_alias_resourcerecordsets.py2
-rw-r--r--tests/integration/route53/test_cert_verification.py2
-rw-r--r--tests/integration/route53/test_health_check.py14
-rw-r--r--tests/integration/route53/test_resourcerecordsets.py2
-rw-r--r--tests/integration/route53/test_zone.py5
-rwxr-xr-xtests/test.py1
-rw-r--r--tests/unit/route53/test_connection.py24
10 files changed, 29 insertions, 30 deletions
diff --git a/README.rst b/README.rst
index 2b8760e0..8c53f57e 100644
--- a/README.rst
+++ b/README.rst
@@ -74,7 +74,7 @@ At the moment, boto supports:
* Networking
- * Amazon Route53
+ * Amazon Route53 (Python 3)
* Amazon Virtual Private Cloud (VPC)
* Elastic Load Balancing (ELB)
* AWS Direct Connect (Python 3)
diff --git a/boto/route53/connection.py b/boto/route53/connection.py
index f0b9f048..2cab2359 100644
--- a/boto/route53/connection.py
+++ b/boto/route53/connection.py
@@ -26,7 +26,6 @@
from boto.route53 import exception
import random
-import urllib
import uuid
import xml.sax
@@ -36,7 +35,7 @@ from boto import handler
import boto.jsonresponse
from boto.route53.record import ResourceRecordSets
from boto.route53.zone import Zone
-from boto.compat import six
+from boto.compat import six, urllib
HZXML = """<?xml version="1.0" encoding="UTF-8"?>
@@ -83,7 +82,7 @@ class Route53Connection(AWSAuthConnection):
for key, val in six.iteritems(params):
if val is None:
continue
- pairs.append(key + '=' + urllib.quote(str(val)))
+ pairs.append(key + '=' + urllib.parse.quote(str(val)))
path += '?' + '&'.join(pairs)
return super(Route53Connection, self).make_request(action, path,
headers, data,
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 7b73d7d6..30bdc9cc 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -80,7 +80,7 @@ Currently Supported Services
* **Networking**
- * :doc:`Route 53 <route53_tut>` -- (:doc:`API Reference <ref/route53>`)
+ * :doc:`Route 53 <route53_tut>` -- (:doc:`API Reference <ref/route53>`) (Python 3)
* :doc:`Virtual Private Cloud (VPC) <vpc_tut>` -- (:doc:`API Reference <ref/vpc>`)
* :doc:`Elastic Load Balancing (ELB) <elb_tut>` -- (:doc:`API Reference <ref/elb>`)
* AWS Direct Connect (Python 3)
diff --git a/tests/integration/route53/test_alias_resourcerecordsets.py b/tests/integration/route53/test_alias_resourcerecordsets.py
index f63787dc..887f8c32 100644
--- a/tests/integration/route53/test_alias_resourcerecordsets.py
+++ b/tests/integration/route53/test_alias_resourcerecordsets.py
@@ -22,7 +22,7 @@
#
import time
-import unittest
+from boto.compat import unittest
from boto.route53.connection import Route53Connection
from boto.route53.record import ResourceRecordSets
from boto.route53.exception import DNSServerError
diff --git a/tests/integration/route53/test_cert_verification.py b/tests/integration/route53/test_cert_verification.py
index 2c209f57..b9a01692 100644
--- a/tests/integration/route53/test_cert_verification.py
+++ b/tests/integration/route53/test_cert_verification.py
@@ -24,7 +24,7 @@
"""
Check that all of the certs on all service endpoints validate.
"""
-import unittest
+from boto.compat import unittest
from nose.plugins.attrib import attr
from tests.integration import ServiceCertVerificationTest
diff --git a/tests/integration/route53/test_health_check.py b/tests/integration/route53/test_health_check.py
index ad336802..bbd5af8f 100644
--- a/tests/integration/route53/test_health_check.py
+++ b/tests/integration/route53/test_health_check.py
@@ -22,6 +22,7 @@
from tests.integration.route53 import Route53TestCase
+from boto.compat import six
from boto.route53.healthcheck import HealthCheck
from boto.route53.record import ResourceRecordSets
@@ -132,18 +133,15 @@ class TestRoute53HealthCheck(Route53TestCase):
'request_interval'.
"""
- with self.assertRaises(AttributeError):
- HealthCheck(**self.health_check_params(request_interval=5))
+ self.assertRaises(AttributeError, lambda: HealthCheck(**self.health_check_params(request_interval=5)))
def test_create_health_check_invalid_failure_threshold(self):
"""
Test that health checks cannot be created with an invalid
'failure_threshold'.
"""
- with self.assertRaises(AttributeError):
- HealthCheck(**self.health_check_params(failure_threshold=0))
- with self.assertRaises(AttributeError):
- HealthCheck(**self.health_check_params(failure_threshold=11))
+ self.assertRaises(AttributeError, lambda: HealthCheck(**self.health_check_params(failure_threshold=0)))
+ self.assertRaises(AttributeError, lambda: HealthCheck(**self.health_check_params(failure_threshold=11)))
def test_create_health_check_request_interval(self):
hc_params = self.health_check_params(request_interval=10)
@@ -152,7 +150,7 @@ class TestRoute53HealthCheck(Route53TestCase):
hc_config = (result[u'CreateHealthCheckResponse']
[u'HealthCheck'][u'HealthCheckConfig'])
self.assertEquals(hc_config[u'RequestInterval'],
- unicode(hc_params['request_interval']))
+ six.text_type(hc_params['request_interval']))
self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])
def test_create_health_check_failure_threshold(self):
@@ -162,7 +160,7 @@ class TestRoute53HealthCheck(Route53TestCase):
hc_config = (result[u'CreateHealthCheckResponse']
[u'HealthCheck'][u'HealthCheckConfig'])
self.assertEquals(hc_config[u'FailureThreshold'],
- unicode(hc_params['failure_threshold']))
+ six.text_type(hc_params['failure_threshold']))
self.conn.delete_health_check(result['CreateHealthCheckResponse']['HealthCheck']['Id'])
def health_check_params(self, **kwargs):
diff --git a/tests/integration/route53/test_resourcerecordsets.py b/tests/integration/route53/test_resourcerecordsets.py
index dcd6d1aa..f26e406e 100644
--- a/tests/integration/route53/test_resourcerecordsets.py
+++ b/tests/integration/route53/test_resourcerecordsets.py
@@ -21,7 +21,7 @@
#
import time
-import unittest
+from boto.compat import unittest
from tests.integration.route53 import Route53TestCase
from boto.route53.connection import Route53Connection
diff --git a/tests/integration/route53/test_zone.py b/tests/integration/route53/test_zone.py
index 449c93f2..02759b47 100644
--- a/tests/integration/route53/test_zone.py
+++ b/tests/integration/route53/test_zone.py
@@ -23,7 +23,7 @@
#
import time
-import unittest
+from boto.compat import unittest
from nose.plugins.attrib import attr
from boto.route53.connection import Route53Connection
from boto.exception import TooManyRecordsException
@@ -151,8 +151,7 @@ class TestRoute53Zone(unittest.TestCase):
identifier=('baz', 'us-east-1'))
self.zone.add_a('exception.%s' % self.base_domain, '8.7.6.5',
identifier=('bam', 'us-west-1'))
- with self.assertRaises(TooManyRecordsException):
- lbrs = self.zone.get_a('exception.%s' % self.base_domain)
+ self.assertRaises(TooManyRecordsException, lambda: self.zone.get_a('exception.%s' % self.base_domain))
self.zone.delete_a('exception.%s' % self.base_domain, all=True)
@classmethod
diff --git a/tests/test.py b/tests/test.py
index 9ed4536e..8aeb95cc 100755
--- a/tests/test.py
+++ b/tests/test.py
@@ -50,6 +50,7 @@ PY3_WHITELIST = (
'tests/unit/manage',
'tests/unit/provider',
'tests/unit/rds2',
+ 'tests/unit/route53',
'tests/unit/s3',
'tests/unit/sns',
'tests/unit/ses',
diff --git a/tests/unit/route53/test_connection.py b/tests/unit/route53/test_connection.py
index eca1fb07..aed4596c 100644
--- a/tests/unit/route53/test_connection.py
+++ b/tests/unit/route53/test_connection.py
@@ -46,7 +46,7 @@ class TestRoute53Connection(AWSMockServiceTestCase):
}
def default_body(self):
- return """<Route53Result>
+ return b"""<Route53Result>
<Message>It failed.</Message>
</Route53Result>
"""
@@ -97,7 +97,7 @@ class TestCreateZoneRoute53(AWSMockServiceTestCase):
super(TestCreateZoneRoute53, self).setUp()
def default_body(self):
- return """
+ return b"""
<CreateHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2012-02-29/">
<HostedZone>
<Id>/hostedzone/Z11111</Id>
@@ -147,7 +147,7 @@ class TestGetZoneRoute53(AWSMockServiceTestCase):
super(TestGetZoneRoute53, self).setUp()
def default_body(self):
- return """
+ return b"""
<ListHostedZonesResponse xmlns="https://route53.amazonaws.com/doc/2012-02-29/">
<HostedZones>
<HostedZone>
@@ -204,7 +204,7 @@ class TestGetHostedZoneRoute53(AWSMockServiceTestCase):
super(TestGetHostedZoneRoute53, self).setUp()
def default_body(self):
- return """
+ return b"""
<GetHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2012-02-29/">
<HostedZone>
<Id>/hostedzone/Z1111</Id>
@@ -241,7 +241,7 @@ class TestGetAllRRSetsRoute53(AWSMockServiceTestCase):
super(TestGetAllRRSetsRoute53, self).setUp()
def default_body(self):
- return """
+ return b"""
<ListResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<ResourceRecordSets>
<ResourceRecordSet>
@@ -320,8 +320,10 @@ class TestGetAllRRSetsRoute53(AWSMockServiceTestCase):
self.set_http_response(status_code=200)
response = self.service_connection.get_all_rrsets("Z1111", "A", "example.com.")
- self.assertEqual(self.actual_request.path,
- "/2013-04-01/hostedzone/Z1111/rrset?type=A&name=example.com.")
+
+ self.assertIn(self.actual_request.path,
+ ("/2013-04-01/hostedzone/Z1111/rrset?type=A&name=example.com.",
+ "/2013-04-01/hostedzone/Z1111/rrset?name=example.com.&type=A"))
self.assertTrue(isinstance(response, ResourceRecordSets))
self.assertEqual(response.hosted_zone_id, "Z1111")
@@ -374,7 +376,7 @@ class TestCreateHealthCheckRoute53IpAddress(AWSMockServiceTestCase):
super(TestCreateHealthCheckRoute53IpAddress, self).setUp()
def default_body(self):
- return """
+ return b"""
<CreateHealthCheckResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<HealthCheck>
<Id>34778cf8-e31e-4974-bad0-b108bd1623d3</Id>
@@ -417,7 +419,7 @@ class TestCreateHealthCheckRoute53FQDN(AWSMockServiceTestCase):
super(TestCreateHealthCheckRoute53FQDN, self).setUp()
def default_body(self):
- return """
+ return b"""
<CreateHealthCheckResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<HealthCheck>
<Id>f9abfe10-8d2a-4bbd-8f35-796f0f8572f2</Id>
@@ -458,7 +460,7 @@ class TestChangeResourceRecordSetsRoute53(AWSMockServiceTestCase):
super(TestChangeResourceRecordSetsRoute53, self).setUp()
def default_body(self):
- return """
+ return b"""
<ChangeResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<ChangeInfo>
<Id>/change/C1111111111111</Id>
@@ -481,7 +483,7 @@ class TestChangeResourceRecordSetsRoute53(AWSMockServiceTestCase):
# the whitespacing doesn't match exactly, so we'll pretty print and drop all new lines
# not the best, but
actual_xml = re.sub(r"\s*[\r\n]+", "\n", xml.dom.minidom.parseString(changes_xml).toprettyxml())
- expected_xml = re.sub(r"\s*[\r\n]+", "\n", xml.dom.minidom.parseString("""
+ expected_xml = re.sub(r"\s*[\r\n]+", "\n", xml.dom.minidom.parseString(b"""
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
<ChangeBatch>
<Comment>None</Comment>