1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Ns1Provider python3

This commit is contained in:
Ross McFarland
2019-10-05 14:38:58 -07:00
parent 37543e6a76
commit 0acff67faa
2 changed files with 11 additions and 7 deletions

View File

@@ -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')