Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: third_party/boto/tests/unit/route53/test_connection.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved 2 # Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved
3 # 3 #
4 # Permission is hereby granted, free of charge, to any person obtaining a 4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the 5 # copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including 6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish, dis- 7 # without limitation the rights to use, copy, modify, merge, publish, dis-
8 # tribute, sublicense, and/or sell copies of the Software, and to permit 8 # tribute, sublicense, and/or sell copies of the Software, and to permit
9 # persons to whom the Software is furnished to do so, subject to the fol- 9 # persons to whom the Software is furnished to do so, subject to the fol-
10 # lowing conditions: 10 # lowing conditions:
11 # 11 #
12 # The above copyright notice and this permission notice shall be included 12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software. 13 # in all copies or substantial portions of the Software.
14 # 14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- 16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 # IN THE SOFTWARE. 21 # IN THE SOFTWARE.
22 # 22 #
23 import mock 23 import mock
24 import re
25 import xml.dom.minidom
24 26
25 from boto.exception import BotoServerError 27 from boto.exception import BotoServerError
26 from boto.route53.connection import Route53Connection 28 from boto.route53.connection import Route53Connection
27 from boto.route53.exception import DNSServerError 29 from boto.route53.exception import DNSServerError
30 from boto.route53.healthcheck import HealthCheck
31 from boto.route53.record import ResourceRecordSets, Record
32 from boto.route53.zone import Zone
28 33
34 from nose.plugins.attrib import attr
29 from tests.unit import unittest 35 from tests.unit import unittest
30 from tests.unit import AWSMockServiceTestCase 36 from tests.unit import AWSMockServiceTestCase
31 37
32 38 @attr(route53=True)
33 class TestRoute53Connection(AWSMockServiceTestCase): 39 class TestRoute53Connection(AWSMockServiceTestCase):
34 connection_class = Route53Connection 40 connection_class = Route53Connection
35 41
36 def setUp(self): 42 def setUp(self):
37 super(TestRoute53Connection, self).setUp() 43 super(TestRoute53Connection, self).setUp()
38 self.calls = { 44 self.calls = {
39 'count': 0, 45 'count': 0,
40 } 46 }
41 47
42 def default_body(self): 48 def default_body(self):
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 self.assertEqual(self.calls['count'], 0) 81 self.assertEqual(self.calls['count'], 0)
76 82
77 # Retries get exhausted. 83 # Retries get exhausted.
78 with self.assertRaises(BotoServerError): 84 with self.assertRaises(BotoServerError):
79 self.service_connection.get_all_hosted_zones() 85 self.service_connection.get_all_hosted_zones()
80 86
81 self.assertEqual(self.calls['count'], 7) 87 self.assertEqual(self.calls['count'], 7)
82 88
83 # Unpatch. 89 # Unpatch.
84 self.service_connection._retry_handler = orig_retry 90 self.service_connection._retry_handler = orig_retry
91
92 @attr(route53=True)
93 class TestCreateZoneRoute53(AWSMockServiceTestCase):
94 connection_class = Route53Connection
95
96 def setUp(self):
97 super(TestCreateZoneRoute53, self).setUp()
98
99 def default_body(self):
100 return """
101 <CreateHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2012-02-29/">
102 <HostedZone>
103 <Id>/hostedzone/Z11111</Id>
104 <Name>example.com.</Name>
105 <CallerReference>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</CallerReference>
106 <Config>
107 <Comment></Comment>
108 </Config>
109 <ResourceRecordSetCount>2</ResourceRecordSetCount>
110 </HostedZone>
111 <ChangeInfo>
112 <Id>/change/C1111111111111</Id>
113 <Status>PENDING</Status>
114 <SubmittedAt>2014-02-02T10:19:29.928Z</SubmittedAt>
115 </ChangeInfo>
116 <DelegationSet>
117 <NameServers>
118 <NameServer>ns-100.awsdns-01.com</NameServer>
119 <NameServer>ns-1000.awsdns-01.co.uk</NameServer>
120 <NameServer>ns-1000.awsdns-01.org</NameServer>
121 <NameServer>ns-900.awsdns-01.net</NameServer>
122 </NameServers>
123 </DelegationSet>
124 </CreateHostedZoneResponse>
125 """
126
127 def test_create_zone(self):
128 self.set_http_response(status_code=201)
129 response = self.service_connection.create_zone("example.com.")
130
131 self.assertTrue(isinstance(response, Zone))
132 self.assertEqual(response.id, "Z11111")
133 self.assertEqual(response.name, "example.com.")
134
135 def test_create_hosted_zone(self):
136 self.set_http_response(status_code=201)
137 response = self.service_connection.create_hosted_zone("example.com.", "m y_ref", "this is a comment")
138
139 self.assertEqual(response['CreateHostedZoneResponse']['DelegationSet'][' NameServers'],
140 ['ns-100.awsdns-01.com', 'ns-1000.awsdns-01.co.uk', 'ns -1000.awsdns-01.org', 'ns-900.awsdns-01.net'])
141
142 @attr(route53=True)
143 class TestGetZoneRoute53(AWSMockServiceTestCase):
144 connection_class = Route53Connection
145
146 def setUp(self):
147 super(TestGetZoneRoute53, self).setUp()
148
149 def default_body(self):
150 return """
151 <ListHostedZonesResponse xmlns="https://route53.amazonaws.com/doc/2012-02-29/">
152 <HostedZones>
153 <HostedZone>
154 <Id>/hostedzone/Z1111</Id>
155 <Name>example2.com.</Name>
156 <CallerReference>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</CallerReferen ce>
157 <Config/>
158 <ResourceRecordSetCount>3</ResourceRecordSetCount>
159 </HostedZone>
160 <HostedZone>
161 <Id>/hostedzone/Z2222</Id>
162 <Name>example1.com.</Name>
163 <CallerReference>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeef</CallerReferen ce>
164 <Config/>
165 <ResourceRecordSetCount>6</ResourceRecordSetCount>
166 </HostedZone>
167 <HostedZone>
168 <Id>/hostedzone/Z3333</Id>
169 <Name>example.com.</Name>
170 <CallerReference>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeeg</CallerReferen ce>
171 <Config/>
172 <ResourceRecordSetCount>6</ResourceRecordSetCount>
173 </HostedZone>
174 </HostedZones>
175 <IsTruncated>false</IsTruncated>
176 <MaxItems>100</MaxItems>
177 </ListHostedZonesResponse>
178 """
179
180 def test_list_zones(self):
181 self.set_http_response(status_code=201)
182 response = self.service_connection.get_all_hosted_zones()
183
184 domains = ['example2.com.', 'example1.com.', 'example.com.']
185 print response['ListHostedZonesResponse']['HostedZones'][0]
186 for d in response['ListHostedZonesResponse']['HostedZones']:
187 print "Removing: %s" % d['Name']
188 domains.remove(d['Name'])
189
190 self.assertEqual(domains, [])
191
192 def test_get_zone(self):
193 self.set_http_response(status_code=201)
194 response = self.service_connection.get_zone('example.com.')
195
196 self.assertTrue(isinstance(response, Zone))
197 self.assertEqual(response.name, "example.com.")
198
199 @attr(route53=True)
200 class TestGetHostedZoneRoute53(AWSMockServiceTestCase):
201 connection_class = Route53Connection
202
203 def setUp(self):
204 super(TestGetHostedZoneRoute53, self).setUp()
205
206 def default_body(self):
207 return """
208 <GetHostedZoneResponse xmlns="https://route53.amazonaws.com/doc/2012-02-29/">
209 <HostedZone>
210 <Id>/hostedzone/Z1111</Id>
211 <Name>example.com.</Name>
212 <CallerReference>aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee</CallerReference>
213 <Config/>
214 <ResourceRecordSetCount>3</ResourceRecordSetCount>
215 </HostedZone>
216 <DelegationSet>
217 <NameServers>
218 <NameServer>ns-1000.awsdns-40.org</NameServer>
219 <NameServer>ns-200.awsdns-30.com</NameServer>
220 <NameServer>ns-900.awsdns-50.net</NameServer>
221 <NameServer>ns-1000.awsdns-00.co.uk</NameServer>
222 </NameServers>
223 </DelegationSet>
224 </GetHostedZoneResponse>
225 """
226
227 def test_list_zones(self):
228 self.set_http_response(status_code=201)
229 response = self.service_connection.get_hosted_zone("Z1111")
230
231 self.assertEqual(response['GetHostedZoneResponse']['HostedZone']['Id'], '/hostedzone/Z1111')
232 self.assertEqual(response['GetHostedZoneResponse']['HostedZone']['Name'] , 'example.com.')
233 self.assertEqual(response['GetHostedZoneResponse']['DelegationSet']['Nam eServers'],
234 ['ns-1000.awsdns-40.org', 'ns-200.awsdns-30.com', 'ns-9 00.awsdns-50.net', 'ns-1000.awsdns-00.co.uk'])
235
236 @attr(route53=True)
237 class TestGetAllRRSetsRoute53(AWSMockServiceTestCase):
238 connection_class = Route53Connection
239
240 def setUp(self):
241 super(TestGetAllRRSetsRoute53, self).setUp()
242
243 def default_body(self):
244 return """
245 <ListResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2013-04 -01/">
246 <ResourceRecordSets>
247 <ResourceRecordSet>
248 <Name>test.example.com.</Name>
249 <Type>A</Type>
250 <TTL>60</TTL>
251 <ResourceRecords>
252 <ResourceRecord>
253 <Value>10.0.0.1</Value>
254 </ResourceRecord>
255 </ResourceRecords>
256 </ResourceRecordSet>
257 <ResourceRecordSet>
258 <Name>www.example.com.</Name>
259 <Type>A</Type>
260 <TTL>60</TTL>
261 <ResourceRecords>
262 <ResourceRecord>
263 <Value>10.0.0.2</Value>
264 </ResourceRecord>
265 </ResourceRecords>
266 </ResourceRecordSet>
267 <ResourceRecordSet>
268 <Name>us-west-2-evaluate-health.example.com.</Name>
269 <Type>A</Type>
270 <SetIdentifier>latency-example-us-west-2-evaluate-health</SetIdentif ier>
271 <Region>us-west-2</Region>
272 <AliasTarget>
273 <HostedZoneId>ABCDEFG123456</HostedZoneId>
274 <EvaluateTargetHealth>true</EvaluateTargetHealth>
275 <DNSName>example-123456-evaluate-health.us-west-2.elb.amazonaws. com.</DNSName>
276 </AliasTarget>
277 </ResourceRecordSet>
278 <ResourceRecordSet>
279 <Name>us-west-2-no-evaluate-health.example.com.</Name>
280 <Type>A</Type>
281 <SetIdentifier>latency-example-us-west-2-no-evaluate-health</SetIden tifier>
282 <Region>us-west-2</Region>
283 <AliasTarget>
284 <HostedZoneId>ABCDEFG567890</HostedZoneId>
285 <EvaluateTargetHealth>false</EvaluateTargetHealth>
286 <DNSName>example-123456-no-evaluate-health.us-west-2.elb.amazona ws.com.</DNSName>
287 </AliasTarget>
288 </ResourceRecordSet>
289 <ResourceRecordSet>
290 <Name>failover.example.com.</Name>
291 <Type>A</Type>
292 <SetIdentifier>failover-primary</SetIdentifier>
293 <Failover>PRIMARY</Failover>
294 <TTL>60</TTL>
295 <ResourceRecords>
296 <ResourceRecord>
297 <Value>10.0.0.4</Value>
298 </ResourceRecord>
299 </ResourceRecords>
300 </ResourceRecordSet>
301 <ResourceRecordSet>
302 <Name>us-west-2-evaluate-health-healthcheck.example.com.</Name>
303 <Type>A</Type>
304 <SetIdentifier>latency-example-us-west-2-evaluate-health-healthcheck </SetIdentifier>
305 <Region>us-west-2</Region>
306 <AliasTarget>
307 <HostedZoneId>ABCDEFG123456</HostedZoneId>
308 <EvaluateTargetHealth>true</EvaluateTargetHealth>
309 <DNSName>example-123456-evaluate-health-healthcheck.us-west-2.el b.amazonaws.com.</DNSName>
310 </AliasTarget>
311 <HealthCheckId>076a32f8-86f7-4c9e-9fa2-c163d5be67d9</HealthCheckId>
312 </ResourceRecordSet>
313 </ResourceRecordSets>
314 <IsTruncated>false</IsTruncated>
315 <MaxItems>100</MaxItems>
316 </ListResourceRecordSetsResponse>
317 """
318
319 def test_get_all_rr_sets(self):
320 self.set_http_response(status_code=200)
321 response = self.service_connection.get_all_rrsets("Z1111", "A", "example .com.")
322
323 self.assertEqual(self.actual_request.path,
324 "/2013-04-01/hostedzone/Z1111/rrset?type=A&name=example .com.")
325
326 self.assertTrue(isinstance(response, ResourceRecordSets))
327 self.assertEqual(response.hosted_zone_id, "Z1111")
328 self.assertTrue(isinstance(response[0], Record))
329
330 self.assertTrue(response[0].name, "test.example.com.")
331 self.assertTrue(response[0].ttl, "60")
332 self.assertTrue(response[0].type, "A")
333
334 evaluate_record = response[2]
335 self.assertEqual(evaluate_record.name, 'us-west-2-evaluate-health.exampl e.com.')
336 self.assertEqual(evaluate_record.type, 'A')
337 self.assertEqual(evaluate_record.identifier, 'latency-example-us-west-2- evaluate-health')
338 self.assertEqual(evaluate_record.region, 'us-west-2')
339 self.assertEqual(evaluate_record.alias_hosted_zone_id, 'ABCDEFG123456')
340 self.assertTrue(evaluate_record.alias_evaluate_target_health)
341 self.assertEqual(evaluate_record.alias_dns_name, 'example-123456-evaluat e-health.us-west-2.elb.amazonaws.com.')
342 evaluate_xml = evaluate_record.to_xml()
343 self.assertTrue('<EvaluateTargetHealth>true</EvaluateTargetHealth>' in e valuate_xml)
344
345 no_evaluate_record = response[3]
346 self.assertEqual(no_evaluate_record.name, 'us-west-2-no-evaluate-health. example.com.')
347 self.assertEqual(no_evaluate_record.type, 'A')
348 self.assertEqual(no_evaluate_record.identifier, 'latency-example-us-west -2-no-evaluate-health')
349 self.assertEqual(no_evaluate_record.region, 'us-west-2')
350 self.assertEqual(no_evaluate_record.alias_hosted_zone_id, 'ABCDEFG567890 ')
351 self.assertFalse(no_evaluate_record.alias_evaluate_target_health)
352 self.assertEqual(no_evaluate_record.alias_dns_name, 'example-123456-no-e valuate-health.us-west-2.elb.amazonaws.com.')
353 no_evaluate_xml = no_evaluate_record.to_xml()
354 self.assertTrue('<EvaluateTargetHealth>false</EvaluateTargetHealth>' in no_evaluate_xml)
355
356 failover_record = response[4]
357 self.assertEqual(failover_record.name, 'failover.example.com.')
358 self.assertEqual(failover_record.type, 'A')
359 self.assertEqual(failover_record.identifier, 'failover-primary')
360 self.assertEqual(failover_record.failover, 'PRIMARY')
361 self.assertEqual(failover_record.ttl, '60')
362
363 healthcheck_record = response[5]
364 self.assertEqual(healthcheck_record.health_check, '076a32f8-86f7-4c9e-9f a2-c163d5be67d9')
365 self.assertEqual(healthcheck_record.name, 'us-west-2-evaluate-health-hea lthcheck.example.com.')
366 self.assertEqual(healthcheck_record.identifier, 'latency-example-us-west -2-evaluate-health-healthcheck')
367 self.assertEqual(healthcheck_record.alias_dns_name, 'example-123456-eval uate-health-healthcheck.us-west-2.elb.amazonaws.com.')
368
369 @attr(route53=True)
370 class TestCreateHealthCheckRoute53IpAddress(AWSMockServiceTestCase):
371 connection_class = Route53Connection
372
373 def setUp(self):
374 super(TestCreateHealthCheckRoute53IpAddress, self).setUp()
375
376 def default_body(self):
377 return """
378 <CreateHealthCheckResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/" >
379 <HealthCheck>
380 <Id>34778cf8-e31e-4974-bad0-b108bd1623d3</Id>
381 <CallerReference>2fa48c8f-76ef-4253-9874-8bcb2b0d7694</CallerReference>
382 <HealthCheckConfig>
383 <IPAddress>74.125.228.81</IPAddress>
384 <Port>443</Port>
385 <Type>HTTPS_STR_MATCH</Type>
386 <SearchString>OK</SearchString>
387 <ResourcePath>/health_check</ResourcePath>
388 <RequestInterval>30</RequestInterval>
389 <FailureThreshold>3</FailureThreshold>
390 </HealthCheckConfig>
391 </HealthCheck>
392 </CreateHealthCheckResponse>
393 """
394
395 def test_create_health_check_ip_address(self):
396 self.set_http_response(status_code=201)
397 hc = HealthCheck(ip_addr='74.125.228.81', port=443, hc_type='HTTPS_STR_M ATCH', resource_path='/health_check', string_match='OK')
398 hc_xml = hc.to_xml()
399 self.assertFalse('<FullyQualifiedDomainName>' in hc_xml)
400 self.assertTrue('<IPAddress>' in hc_xml)
401
402 response = self.service_connection.create_health_check(hc)
403 hc_resp = response['CreateHealthCheckResponse']['HealthCheck']['HealthCh eckConfig']
404 self.assertEqual(hc_resp['IPAddress'], '74.125.228.81')
405 self.assertEqual(hc_resp['ResourcePath'], '/health_check')
406 self.assertEqual(hc_resp['Type'], 'HTTPS_STR_MATCH')
407 self.assertEqual(hc_resp['Port'], '443')
408 self.assertEqual(hc_resp['ResourcePath'], '/health_check')
409 self.assertEqual(hc_resp['SearchString'], 'OK')
410 self.assertEqual(response['CreateHealthCheckResponse']['HealthCheck']['I d'], '34778cf8-e31e-4974-bad0-b108bd1623d3')
411
412 @attr(route53=True)
413 class TestCreateHealthCheckRoute53FQDN(AWSMockServiceTestCase):
414 connection_class = Route53Connection
415
416 def setUp(self):
417 super(TestCreateHealthCheckRoute53FQDN, self).setUp()
418
419 def default_body(self):
420 return """
421 <CreateHealthCheckResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/" >
422 <HealthCheck>
423 <Id>f9abfe10-8d2a-4bbd-8f35-796f0f8572f2</Id>
424 <CallerReference>3246ac17-b651-4295-a5c8-c132a59693d7</CallerReference>
425 <HealthCheckConfig>
426 <Port>443</Port>
427 <Type>HTTPS</Type>
428 <ResourcePath>/health_check</ResourcePath>
429 <FullyQualifiedDomainName>example.com</FullyQualifiedDomainName>
430 <RequestInterval>30</RequestInterval>
431 <FailureThreshold>3</FailureThreshold>
432 </HealthCheckConfig>
433 </HealthCheck>
434 </CreateHealthCheckResponse>
435 """
436
437 def test_create_health_check_fqdn(self):
438 self.set_http_response(status_code=201)
439 hc = HealthCheck(ip_addr='', port=443, hc_type='HTTPS', resource_path='/ health_check', fqdn='example.com')
440 hc_xml = hc.to_xml()
441 self.assertTrue('<FullyQualifiedDomainName>' in hc_xml)
442 self.assertFalse('<IPAddress>' in hc_xml)
443
444 response = self.service_connection.create_health_check(hc)
445 hc_resp = response['CreateHealthCheckResponse']['HealthCheck']['HealthCh eckConfig']
446 self.assertEqual(hc_resp['FullyQualifiedDomainName'], 'example.com')
447 self.assertEqual(hc_resp['ResourcePath'], '/health_check')
448 self.assertEqual(hc_resp['Type'], 'HTTPS')
449 self.assertEqual(hc_resp['Port'], '443')
450 self.assertEqual(hc_resp['ResourcePath'], '/health_check')
451 self.assertEqual(response['CreateHealthCheckResponse']['HealthCheck']['I d'], 'f9abfe10-8d2a-4bbd-8f35-796f0f8572f2')
452
453 @attr(route53=True)
454 class TestChangeResourceRecordSetsRoute53(AWSMockServiceTestCase):
455 connection_class = Route53Connection
456
457 def setUp(self):
458 super(TestChangeResourceRecordSetsRoute53, self).setUp()
459
460 def default_body(self):
461 return """
462 <ChangeResourceRecordSetsResponse xmlns="https://route53.amazonaws.com/doc/2013- 04-01/">
463 <ChangeInfo>
464 <Id>/change/C1111111111111</Id>
465 <Status>PENDING</Status>
466 <SubmittedAt>2014-05-05T10:11:12.123Z</SubmittedAt>
467 </ChangeInfo>
468 </ChangeResourceRecordSetsResponse>
469 """
470
471 def test_record_commit(self):
472 rrsets = ResourceRecordSets(self.service_connection)
473 rrsets.add_change_record('CREATE', Record('vanilla.example.com', 'A', 60 , ['1.2.3.4']))
474 rrsets.add_change_record('CREATE', Record('alias.example.com', 'AAAA', a lias_hosted_zone_id='Z123OTHER', alias_dns_name='target.other', alias_evaluate_t arget_health=True))
475 rrsets.add_change_record('CREATE', Record('wrr.example.com', 'CNAME', 60 , ['cname.target'], weight=10, identifier='weight-1'))
476 rrsets.add_change_record('CREATE', Record('lbr.example.com', 'TXT', 60, ['text record'], region='us-west-2', identifier='region-1'))
477 rrsets.add_change_record('CREATE', Record('failover.example.com', 'A', 6 0, ['2.2.2.2'], health_check='hc-1234', failover='PRIMARY', identifier='primary' ))
478
479 changes_xml = rrsets.to_xml()
480
481 # the whitespacing doesn't match exactly, so we'll pretty print and drop all new lines
482 # not the best, but
483 actual_xml = re.sub(r"\s*[\r\n]+", "\n", xml.dom.minidom.parseString(cha nges_xml).toprettyxml())
484 expected_xml = re.sub(r"\s*[\r\n]+", "\n", xml.dom.minidom.parseString(" ""
485 <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-0 4-01/">
486 <ChangeBatch>
487 <Comment>None</Comment>
488 <Changes>
489 <Change>
490 <Action>CREATE</Action>
491 <ResourceRecordSet>
492 <Name>vanilla.example.com</Name>
493 <Type>A</Type>
494 <TTL>60</TTL>
495 <ResourceRecords>
496 <ResourceRecord>
497 <Value>1.2.3.4</Value>
498 </ResourceRecord>
499 </ResourceRecords>
500 </ResourceRecordSet>
501 </Change>
502 <Change>
503 <Action>CREATE</Action>
504 <ResourceRecordSet>
505 <Name>alias.example.com</Name>
506 <Type>AAAA</Type>
507 <AliasTarget>
508 <HostedZoneId>Z123OTHER</HostedZoneId>
509 <DNSName>target.other</DNSName>
510 <EvaluateTargetHealth>true</EvaluateTargetHealth>
511 </AliasTarget>
512 </ResourceRecordSet>
513 </Change>
514 <Change>
515 <Action>CREATE</Action>
516 <ResourceRecordSet>
517 <Name>wrr.example.com</Name>
518 <Type>CNAME</Type>
519 <SetIdentifier>weight-1</SetIdentifier>
520 <Weight>10</Weight>
521 <TTL>60</TTL>
522 <ResourceRecords>
523 <ResourceRecord>
524 <Value>cname.target</Value>
525 </ResourceRecord>
526 </ResourceRecords>
527 </ResourceRecordSet>
528 </Change>
529 <Change>
530 <Action>CREATE</Action>
531 <ResourceRecordSet>
532 <Name>lbr.example.com</Name>
533 <Type>TXT</Type>
534 <SetIdentifier>region-1</SetIdentifier>
535 <Region>us-west-2</Region>
536 <TTL>60</TTL>
537 <ResourceRecords>
538 <ResourceRecord>
539 <Value>text record</Value>
540 </ResourceRecord>
541 </ResourceRecords>
542 </ResourceRecordSet>
543 </Change>
544 <Change>
545 <Action>CREATE</Action>
546 <ResourceRecordSet>
547 <Name>failover.example.com</Name>
548 <Type>A</Type>
549 <SetIdentifier>primary</SetIdentifier>
550 <Failover>PRIMARY</Failover>
551 <TTL>60</TTL>
552 <ResourceRecords>
553 <ResourceRecord>
554 <Value>2.2.2.2</Value>
555 </ResourceRecord>
556 </ResourceRecords>
557 <HealthCheckId>hc-1234</HealthCheckId>
558 </ResourceRecordSet>
559 </Change>
560 </Changes>
561 </ChangeBatch>
562 </ChangeResourceRecordSetsRequest>
563 """).toprettyxml())
564
565 # Note: the alias XML should not include the TTL, even if it's specified in the object model
566 self.assertEqual(actual_xml, expected_xml)
567
OLDNEW
« no previous file with comments | « third_party/boto/tests/unit/rds2/test_connection.py ('k') | third_party/boto/tests/unit/s3/test_bucket.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698