mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Use target.id instead of class name
This commit is contained in:
@@ -111,12 +111,12 @@ class Zone(object):
|
||||
if record.ignored:
|
||||
continue
|
||||
elif len(record.included) > 0 and \
|
||||
target.__class__.__name__ not in record.included:
|
||||
target.id not in record.included:
|
||||
self.log.debug('changes: skipping record=%s %s - %s not'
|
||||
' included ', record.fqdn, record._type,
|
||||
target.id)
|
||||
continue
|
||||
elif target.__class__.__name__ in record.excluded:
|
||||
elif target.id in record.excluded:
|
||||
self.log.debug('changes: skipping record=%s %s - %s '
|
||||
'excluded ', record.fqdn, record._type,
|
||||
target.id)
|
||||
@@ -126,12 +126,12 @@ class Zone(object):
|
||||
if desired_record.ignored:
|
||||
continue
|
||||
elif len(record.included) > 0 and \
|
||||
target.__class__.__name__ not in record.included:
|
||||
target.id not in record.included:
|
||||
self.log.debug('changes: skipping record=%s %s - %s'
|
||||
'not included ', record.fqdn, record._type,
|
||||
target.id)
|
||||
continue
|
||||
elif target.__class__.__name__ in record.excluded:
|
||||
elif target.id in record.excluded:
|
||||
continue
|
||||
except KeyError:
|
||||
if not target.supports(record):
|
||||
@@ -161,12 +161,12 @@ class Zone(object):
|
||||
if record.ignored:
|
||||
continue
|
||||
elif len(record.included) > 0 and \
|
||||
target.__class__.__name__ not in record.included:
|
||||
target.id not in record.included:
|
||||
self.log.debug('changes: skipping record=%s %s - %s not'
|
||||
' included ', record.fqdn, record._type,
|
||||
target.id)
|
||||
continue
|
||||
elif target.__class__.__name__ in record.excluded:
|
||||
elif target.id in record.excluded:
|
||||
self.log.debug('changes: skipping record=%s %s - %s '
|
||||
'excluded ', record.fqdn, record._type,
|
||||
target.id)
|
||||
|
@@ -59,9 +59,9 @@ cname:
|
||||
excluded:
|
||||
octodns:
|
||||
excluded:
|
||||
- CloudflareProvider
|
||||
- test
|
||||
type: CNAME
|
||||
value: excluded.unit.tests.
|
||||
value: unit.tests.
|
||||
ignored:
|
||||
octodns:
|
||||
ignored: true
|
||||
@@ -70,9 +70,9 @@ ignored:
|
||||
included:
|
||||
octodns:
|
||||
included:
|
||||
- DnsimpleProvider
|
||||
- test
|
||||
type: CNAME
|
||||
value: included.unit.tests.
|
||||
value: unit.tests.
|
||||
mx:
|
||||
ttl: 300
|
||||
type: MX
|
||||
|
@@ -139,14 +139,31 @@
|
||||
"meta": {
|
||||
"auto_added": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "fc12ab34cd5611334422ab3322997656",
|
||||
"type": "CNAME",
|
||||
"name": "included.unit.tests",
|
||||
"content": "unit.tests",
|
||||
"proxiable": true,
|
||||
"proxied": false,
|
||||
"ttl": 3600,
|
||||
"locked": false,
|
||||
"zone_id": "ff12ab34cd5611334422ab3322997650",
|
||||
"zone_name": "unit.tests",
|
||||
"modified_on": "2017-03-11T18:01:43.940682Z",
|
||||
"created_on": "2017-03-11T18:01:43.940682Z",
|
||||
"meta": {
|
||||
"auto_added": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"result_info": {
|
||||
"page": 2,
|
||||
"per_page": 10,
|
||||
"total_pages": 2,
|
||||
"count": 8,
|
||||
"total_count": 19
|
||||
"count": 9,
|
||||
"total_count": 20
|
||||
},
|
||||
"success": true,
|
||||
"errors": [],
|
||||
|
20
tests/fixtures/dnsimple-page-2.json
vendored
20
tests/fixtures/dnsimple-page-2.json
vendored
@@ -176,28 +176,12 @@
|
||||
"created_at": "2017-03-09T15:55:09Z",
|
||||
"updated_at": "2017-03-09T15:55:09Z"
|
||||
},
|
||||
{
|
||||
"id": 12188804,
|
||||
"zone_id": "unit.tests",
|
||||
"parent_id": null,
|
||||
"name": "excluded",
|
||||
"content": "excluded.unit.tests",
|
||||
"ttl": 3600,
|
||||
"priority": null,
|
||||
"type": "CNAME",
|
||||
"regions": [
|
||||
"global"
|
||||
],
|
||||
"system_record": false,
|
||||
"created_at": "2017-03-09T15:55:09Z",
|
||||
"updated_at": "2017-03-09T15:55:09Z"
|
||||
},
|
||||
{
|
||||
"id": 12188805,
|
||||
"zone_id": "unit.tests",
|
||||
"parent_id": null,
|
||||
"name": "included",
|
||||
"content": "included.unit.tests",
|
||||
"content": "unit.tests",
|
||||
"ttl": 3600,
|
||||
"priority": null,
|
||||
"type": "CNAME",
|
||||
@@ -212,7 +196,7 @@
|
||||
"pagination": {
|
||||
"current_page": 2,
|
||||
"per_page": 20,
|
||||
"total_entries": 30,
|
||||
"total_entries": 32,
|
||||
"total_pages": 2
|
||||
}
|
||||
}
|
||||
|
4
tests/fixtures/powerdns-full-data.json
vendored
4
tests/fixtures/powerdns-full-data.json
vendored
@@ -245,10 +245,10 @@
|
||||
},
|
||||
{
|
||||
"comments": [],
|
||||
"name": "excluded.unit.tests.",
|
||||
"name": "included.unit.tests.",
|
||||
"records": [
|
||||
{
|
||||
"content": "excluded.unit.tests.",
|
||||
"content": "unit.tests.",
|
||||
"disabled": false
|
||||
}
|
||||
],
|
||||
|
@@ -18,6 +18,7 @@ class SimpleSource(object):
|
||||
class SimpleProvider(object):
|
||||
SUPPORTS_GEO = False
|
||||
SUPPORTS = set(('A',))
|
||||
id = 'test'
|
||||
|
||||
def __init__(self, id='test'):
|
||||
pass
|
||||
@@ -34,6 +35,7 @@ class SimpleProvider(object):
|
||||
|
||||
class GeoProvider(object):
|
||||
SUPPORTS_GEO = True
|
||||
id = 'test'
|
||||
|
||||
def __init__(self, id='test'):
|
||||
pass
|
||||
|
@@ -17,6 +17,7 @@ class HelperProvider(BaseProvider):
|
||||
log = getLogger('HelperProvider')
|
||||
|
||||
SUPPORTS = set(('A',))
|
||||
id = 'test'
|
||||
|
||||
def __init__(self, extra_changes, apply_disabled=False,
|
||||
include_change_callback=None):
|
||||
|
@@ -118,7 +118,7 @@ class TestCloudflareProvider(TestCase):
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(10, len(zone.records))
|
||||
self.assertEquals(11, len(zone.records))
|
||||
|
||||
changes = self.expected.changes(zone, provider)
|
||||
self.assertEquals(0, len(changes))
|
||||
@@ -126,7 +126,7 @@ class TestCloudflareProvider(TestCase):
|
||||
# re-populating the same zone/records comes out of cache, no calls
|
||||
again = Zone('unit.tests.', [])
|
||||
provider.populate(again)
|
||||
self.assertEquals(10, len(again.records))
|
||||
self.assertEquals(11, len(again.records))
|
||||
|
||||
def test_apply(self):
|
||||
provider = CloudflareProvider('test', 'email', 'token')
|
||||
@@ -140,12 +140,12 @@ class TestCloudflareProvider(TestCase):
|
||||
'id': 42,
|
||||
}
|
||||
}, # zone create
|
||||
] + [None] * 17 # individual record creates
|
||||
] + [None] * 18 # individual record creates
|
||||
|
||||
# non-existant zone, create everything
|
||||
plan = provider.plan(self.expected)
|
||||
self.assertEquals(10, len(plan.changes))
|
||||
self.assertEquals(10, provider.apply(plan))
|
||||
self.assertEquals(11, len(plan.changes))
|
||||
self.assertEquals(11, provider.apply(plan))
|
||||
|
||||
provider._request.assert_has_calls([
|
||||
# created the domain
|
||||
@@ -170,7 +170,7 @@ class TestCloudflareProvider(TestCase):
|
||||
}),
|
||||
], True)
|
||||
# expected number of total calls
|
||||
self.assertEquals(19, provider._request.call_count)
|
||||
self.assertEquals(20, provider._request.call_count)
|
||||
|
||||
provider._request.reset_mock()
|
||||
|
||||
|
@@ -78,14 +78,14 @@ class TestDnsimpleProvider(TestCase):
|
||||
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(17, len(zone.records))
|
||||
self.assertEquals(16, len(zone.records))
|
||||
changes = self.expected.changes(zone, provider)
|
||||
self.assertEquals(0, len(changes))
|
||||
|
||||
# 2nd populate makes no network calls/all from cache
|
||||
again = Zone('unit.tests.', [])
|
||||
provider.populate(again)
|
||||
self.assertEquals(17, len(again.records))
|
||||
self.assertEquals(16, len(again.records))
|
||||
|
||||
# bust the cache
|
||||
del provider._zone_records[zone.name]
|
||||
@@ -129,8 +129,8 @@ class TestDnsimpleProvider(TestCase):
|
||||
]
|
||||
plan = provider.plan(self.expected)
|
||||
|
||||
# No root NS, no ignored
|
||||
n = len(self.expected.records) - 2
|
||||
# No root NS, no ignored, no excluded
|
||||
n = len(self.expected.records) - 3
|
||||
self.assertEquals(n, len(plan.changes))
|
||||
self.assertEquals(n, provider.apply(plan))
|
||||
|
||||
@@ -147,7 +147,7 @@ class TestDnsimpleProvider(TestCase):
|
||||
}),
|
||||
])
|
||||
# expected number of total calls
|
||||
self.assertEquals(29, provider._client._request.call_count)
|
||||
self.assertEquals(28, provider._client._request.call_count)
|
||||
|
||||
provider._client._request.reset_mock()
|
||||
|
||||
|
Reference in New Issue
Block a user