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