mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Ns1Provider python3
This commit is contained in:
@@ -10,7 +10,7 @@ from itertools import chain
|
||||
from collections import OrderedDict, defaultdict
|
||||
from nsone import NSONE
|
||||
from nsone.rest.errors import RateLimitException, ResourceException
|
||||
from incf.countryutils import transformations
|
||||
from pycountry_convert import country_alpha2_to_continent_code
|
||||
from time import sleep
|
||||
|
||||
from six import text_type
|
||||
@@ -62,8 +62,7 @@ class Ns1Provider(BaseProvider):
|
||||
us_state = meta.get('us_state', [])
|
||||
ca_province = meta.get('ca_province', [])
|
||||
for cntry in country:
|
||||
cn = transformations.cc_to_cn(cntry)
|
||||
con = transformations.cn_to_ctca2(cn)
|
||||
con = country_alpha2_to_continent_code(cntry)
|
||||
key = '{}-{}'.format(con, cntry)
|
||||
geo[key].extend(answer['answer'])
|
||||
for state in us_state:
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
from __future__ import absolute_import, division, print_function, \
|
||||
unicode_literals
|
||||
|
||||
from collections import defaultdict
|
||||
from mock import Mock, call, patch
|
||||
from nsone.rest.errors import AuthException, RateLimitException, \
|
||||
ResourceException
|
||||
@@ -373,8 +374,12 @@ class TestNs1Provider(TestCase):
|
||||
load_mock.side_effect = [nsone_zone, nsone_zone]
|
||||
plan = provider.plan(desired)
|
||||
self.assertEquals(3, len(plan.changes))
|
||||
self.assertIsInstance(plan.changes[0], Update)
|
||||
self.assertIsInstance(plan.changes[2], Delete)
|
||||
# Shouldn't rely on order so just count classes
|
||||
classes = defaultdict(lambda: 0)
|
||||
for change in plan.changes:
|
||||
classes[change.__class__] += 1
|
||||
self.assertEquals(1, classes[Delete])
|
||||
self.assertEquals(2, classes[Update])
|
||||
# ugh, we need a mock record that can be returned from loadRecord for
|
||||
# the update and delete targets, we can add our side effects to that to
|
||||
# trigger rate limit handling
|
||||
@@ -397,7 +402,7 @@ class TestNs1Provider(TestCase):
|
||||
call('unit.tests', u'A'),
|
||||
call('geo', u'A'),
|
||||
call('delete-me', u'A'),
|
||||
])
|
||||
], any_order=True)
|
||||
mock_record.assert_has_calls([
|
||||
call.update(answers=[{'answer': [u'1.2.3.4'], 'meta': {}}],
|
||||
filters=[],
|
||||
@@ -424,7 +429,7 @@ class TestNs1Provider(TestCase):
|
||||
ttl=34),
|
||||
call.delete(),
|
||||
call.delete()
|
||||
])
|
||||
], any_order=True)
|
||||
|
||||
def test_escaping(self):
|
||||
provider = Ns1Provider('test', 'api-key')
|
||||
|
||||
Reference in New Issue
Block a user