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