mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Implement populate exists for Ns1Provider
This commit is contained in:
@@ -190,11 +190,13 @@ class Ns1Provider(BaseProvider):
|
|||||||
nsone_zone = self._client.loadZone(zone.name[:-1])
|
nsone_zone = self._client.loadZone(zone.name[:-1])
|
||||||
records = nsone_zone.data['records']
|
records = nsone_zone.data['records']
|
||||||
geo_records = nsone_zone.search(has_geo=True)
|
geo_records = nsone_zone.search(has_geo=True)
|
||||||
|
exists = True
|
||||||
except ResourceException as e:
|
except ResourceException as e:
|
||||||
if e.message != self.ZONE_NOT_FOUND_MESSAGE:
|
if e.message != self.ZONE_NOT_FOUND_MESSAGE:
|
||||||
raise
|
raise
|
||||||
records = []
|
records = []
|
||||||
geo_records = []
|
geo_records = []
|
||||||
|
exists = False
|
||||||
|
|
||||||
before = len(zone.records)
|
before = len(zone.records)
|
||||||
# geo information isn't returned from the main endpoint, so we need
|
# geo information isn't returned from the main endpoint, so we need
|
||||||
@@ -208,8 +210,9 @@ class Ns1Provider(BaseProvider):
|
|||||||
source=self, lenient=lenient)
|
source=self, lenient=lenient)
|
||||||
zone_hash[(_type, name)] = record
|
zone_hash[(_type, name)] = record
|
||||||
[zone.add_record(r) for r in zone_hash.values()]
|
[zone.add_record(r) for r in zone_hash.values()]
|
||||||
self.log.info('populate: found %s records',
|
self.log.info('populate: found %s records, exists=%s',
|
||||||
len(zone.records) - before)
|
len(zone.records) - before, exists)
|
||||||
|
return exists
|
||||||
|
|
||||||
def _params_for_A(self, record):
|
def _params_for_A(self, record):
|
||||||
params = {'answers': record.values, 'ttl': record.ttl}
|
params = {'answers': record.values, 'ttl': record.ttl}
|
||||||
|
@@ -196,9 +196,10 @@ class TestNs1Provider(TestCase):
|
|||||||
load_mock.side_effect = \
|
load_mock.side_effect = \
|
||||||
ResourceException('server error: zone not found')
|
ResourceException('server error: zone not found')
|
||||||
zone = Zone('unit.tests.', [])
|
zone = Zone('unit.tests.', [])
|
||||||
provider.populate(zone)
|
exists = provider.populate(zone)
|
||||||
self.assertEquals(set(), zone.records)
|
self.assertEquals(set(), zone.records)
|
||||||
self.assertEquals(('unit.tests',), load_mock.call_args[0])
|
self.assertEquals(('unit.tests',), load_mock.call_args[0])
|
||||||
|
self.assertFalse(exists)
|
||||||
|
|
||||||
# Existing zone w/o records
|
# Existing zone w/o records
|
||||||
load_mock.reset_mock()
|
load_mock.reset_mock()
|
||||||
@@ -269,6 +270,7 @@ class TestNs1Provider(TestCase):
|
|||||||
# everything except the root NS
|
# everything except the root NS
|
||||||
expected_n = len(self.expected) - 1
|
expected_n = len(self.expected) - 1
|
||||||
self.assertEquals(expected_n, len(plan.changes))
|
self.assertEquals(expected_n, len(plan.changes))
|
||||||
|
self.assertTrue(plan.exists)
|
||||||
|
|
||||||
# Fails, general error
|
# Fails, general error
|
||||||
load_mock.reset_mock()
|
load_mock.reset_mock()
|
||||||
|
Reference in New Issue
Block a user