From 852381b81070e375f416ab68e0658555c3949b26 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Tue, 9 May 2017 14:45:35 -0700 Subject: [PATCH] Add test for Route53Provider geo -> plain conversion --- octodns/provider/route53.py | 3 +- tests/test_octodns_provider_route53.py | 64 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/octodns/provider/route53.py b/octodns/provider/route53.py index 46ad443..3849561 100644 --- a/octodns/provider/route53.py +++ b/octodns/provider/route53.py @@ -90,7 +90,8 @@ class _Route53Record(object): elif self.geo: geo = self.geo rrset['SetIdentifier'] = geo.code - rrset['HealthCheckId'] = self.health_check_id + if self.health_check_id: + rrset['HealthCheckId'] = self.health_check_id if geo.subdivision_code: rrset['GeoLocation'] = { 'CountryCode': geo.country_code, diff --git a/tests/test_octodns_provider_route53.py b/tests/test_octodns_provider_route53.py index bdc1803..e1a73f8 100644 --- a/tests/test_octodns_provider_route53.py +++ b/tests/test_octodns_provider_route53.py @@ -500,6 +500,70 @@ class TestRoute53Provider(TestCase): self.assertEquals(1, provider.apply(plan)) stubber.assert_no_pending_responses() + # Update converting to non-geo by monkey patching in a populate that + # modifies the A record with geos + def mod_add_geo_populate(existing, target): + for record in self.expected.records: + if record._type != 'A' or record.geo: + existing.records.add(record) + record = Record.new(existing, 'simple', { + 'ttl': 61, + 'type': 'A', + 'values': ['1.2.3.4', '2.2.3.4'], + 'geo': { + 'OC': ['3.2.3.4', '4.2.3.4'], + } + }) + existing.records.add(record) + + provider.populate = mod_add_geo_populate + change_resource_record_sets_params = { + 'ChangeBatch': { + 'Changes': [{ + 'Action': 'DELETE', + 'ResourceRecordSet': { + 'GeoLocation': {'ContinentCode': 'OC'}, + 'Name': 'simple.unit.tests.', + 'ResourceRecords': [{'Value': '3.2.3.4'}, + {'Value': '4.2.3.4'}], + 'SetIdentifier': 'OC', + 'TTL': 61, + 'Type': 'A'} + }, { + 'Action': 'DELETE', + 'ResourceRecordSet': { + 'GeoLocation': {'CountryCode': '*'}, + 'Name': 'simple.unit.tests.', + 'ResourceRecords': [{'Value': '1.2.3.4'}, + {'Value': '2.2.3.4'}], + 'SetIdentifier': 'default', + 'TTL': 61, + 'Type': 'A'} + }, { + 'Action': 'CREATE', + 'ResourceRecordSet': { + 'Name': 'simple.unit.tests.', + 'ResourceRecords': [{'Value': '1.2.3.4'}, + {'Value': '2.2.3.4'}], + 'TTL': 60, + 'Type': 'A'} + }], + 'Comment': ANY + }, + 'HostedZoneId': 'z42' + } + stubber.add_response('change_resource_record_sets', + {'ChangeInfo': { + 'Id': 'id', + 'Status': 'PENDING', + 'SubmittedAt': '2017-01-29T01:02:03Z', + }}, change_resource_record_sets_params) + plan = provider.plan(self.expected) + self.assertEquals(1, len(plan.changes)) + self.assertIsInstance(plan.changes[0], Update) + self.assertEquals(1, provider.apply(plan)) + stubber.assert_no_pending_responses() + def test_sync_create(self): provider, stubber = self._get_stubbed_provider()