def test_client_max_attempts(self):
     provider = Route53Provider('test', 'abc', '123',
                                client_max_attempts=42)
     # NOTE: this will break if boto ever changes the impl details...
     self.assertEquals(43, provider._conn.meta.events
                       ._unique_id_handlers['retry-config-route53']
                       ['handler']._checker.__dict__['_max_attempts'])
    def _get_stubbed_provider(self):
        provider = Route53Provider('test', 'abc', '123')

        # Use the stubber
        stubber = Stubber(provider._conn)
        stubber.activate()

        return (provider, stubber)
    def _get_stubbed_fallback_auth_provider(self):
        provider = Route53Provider('test')

        # Use the stubber
        stubber = Stubber(provider._conn)
        stubber.activate()

        return (provider, stubber)
    def test_semicolon_fixup(self):
        provider = Route53Provider('test', 'abc', '123')

        self.assertEquals({
            'type': 'TXT',
            'ttl': 30,
            'values': [
                'abcd\\; ef\\;g',
                'hij\\; klm\\;n',
            ],
        }, provider._data_for_quoted({
            'ResourceRecords': [{
                'Value': '"abcd; ef;g"',
            }, {
                'Value': '"hij\\; klm\\;n"',
            }],
            'TTL': 30,
            'Type': 'TXT',
        }))
    def _get_test_plan(self, max_changes):

        provider = Route53Provider('test', 'abc', '123', max_changes)

        # Use the stubber
        stubber = Stubber(provider._conn)
        stubber.activate()

        got = Zone('unit.tests.', [])

        list_hosted_zones_resp = {
            'HostedZones': [],
            'Marker': 'm',
            'IsTruncated': False,
            'MaxItems': '100',
        }
        stubber.add_response('list_hosted_zones', list_hosted_zones_resp,
                             {})

        create_hosted_zone_resp = {
            'HostedZone': {
                'Name': 'unit.tests.',
                'Id': 'z42',
                'CallerReference': 'abc',
            },
            'ChangeInfo': {
                'Id': 'a12',
                'Status': 'PENDING',
                'SubmittedAt': '2017-01-29T01:02:03Z',
                'Comment': 'hrm',
            },
            'DelegationSet': {
                'Id': 'b23',
                'CallerReference': 'blip',
                'NameServers': [
                    'n12.unit.tests.',
                ],
            },
            'Location': 'us-east-1',
        }
        stubber.add_response('create_hosted_zone',
                             create_hosted_zone_resp, {
                                 'Name': got.name,
                                 'CallerReference': ANY,
                             })

        stubber.add_response('list_health_checks',
                             {
                                 'HealthChecks': self.health_checks,
                                 'IsTruncated': False,
                                 'MaxItems': '100',
                                 'Marker': '',
                             })

        stubber.add_response('change_resource_record_sets',
                             {'ChangeInfo': {
                                 'Id': 'id',
                                 'Status': 'PENDING',
                                 'SubmittedAt': '2017-01-29T01:02:03Z',
                             }}, {'HostedZoneId': 'z42', 'ChangeBatch': ANY})

        plan = provider.plan(self.expected)

        return provider, plan