From 0e762624c4e6de6e6b763f0e90ffc5f77151f041 Mon Sep 17 00:00:00 2001 From: Wil Tan Date: Tue, 26 Aug 2014 13:51:20 +1000 Subject: paged get_all_rrsets test case (refs #2542) --- tests/unit/route53/test_connection.py | 100 +++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 1 deletion(-) diff --git a/tests/unit/route53/test_connection.py b/tests/unit/route53/test_connection.py index 16df3747..f1d5d8e6 100644 --- a/tests/unit/route53/test_connection.py +++ b/tests/unit/route53/test_connection.py @@ -23,7 +23,6 @@ from tests.compat import mock, unittest import re import xml.dom.minidom - from boto.exception import BotoServerError from boto.route53.connection import Route53Connection from boto.route53.exception import DNSServerError @@ -33,6 +32,8 @@ from boto.route53.zone import Zone from nose.plugins.attrib import attr from tests.unit import AWSMockServiceTestCase +from boto.compat import six +urllib = six.moves.urllib @attr(route53=True) class TestRoute53Connection(AWSMockServiceTestCase): @@ -371,6 +372,103 @@ class TestGetAllRRSetsRoute53(AWSMockServiceTestCase): self.assertEqual(healthcheck_record.identifier, 'latency-example-us-west-2-evaluate-health-healthcheck') self.assertEqual(healthcheck_record.alias_dns_name, 'example-123456-evaluate-health-healthcheck.us-west-2.elb.amazonaws.com.') +@attr(route53=True) +class TestTruncatedGetAllRRSetsRoute53(AWSMockServiceTestCase): + connection_class = Route53Connection + + def setUp(self): + super(TestTruncatedGetAllRRSetsRoute53, self).setUp() + + def default_body(self): + return b""" + + + + example.com. + NS + 900 + + + ns-91.awsdns-41.co.uk. + + + ns-1929.awsdns-93.net. + + + ns-12.awsdns-21.org. + + + ns-102.awsdns-96.com. + + + + + example.com. + SOA + 1800 + + + ns-1929.awsdns-93.net. hostmaster.awsdns.net. 1 10800 3600 604800 1800 + + + + + wrr.example.com. + A + primary + 100 + 300 + + 127.0.0.1 + + + + true + wrr.example.com. + A + secondary + 3 +""" + + def paged_body(self): + return b""" + + + + wrr.example.com. + A + secondary + 50 + 300 + + 127.0.0.2 + + + + false + 3 +""" + + + def test_get_all_rr_sets(self): + self.set_http_response(status_code=200) + response = self.service_connection.get_all_rrsets("Z1111", maxitems=3) + + # made first request + self.assertEqual(self.actual_request.path, '/2013-04-01/hostedzone/Z1111/rrset?maxitems=3') + + # anticipate a second request when we page it + self.set_http_response(status_code=200, body=self.paged_body()) + + # this should trigger another call to get_all_rrsets + self.assertEqual(len(list(response)), 4) + + url_parts = urllib.parse.urlparse(self.actual_request.path) + self.assertEqual(url_parts.path, '/2013-04-01/hostedzone/Z1111/rrset') + self.assertEqual(urllib.parse.parse_qs(url_parts.query), + dict(type=['A'], name=['wrr.example.com.'], identifier=['secondary'])) + + @attr(route53=True) class TestCreateHealthCheckRoute53IpAddress(AWSMockServiceTestCase): connection_class = Route53Connection -- cgit v1.2.1