mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge pull request #227 from tommyang/bugfix/skipping-unsupported-records
Skip unsupported records for NS1 & DNSimple
This commit is contained in:
@@ -256,7 +256,7 @@ class DnsimpleProvider(BaseProvider):
|
||||
values = defaultdict(lambda: defaultdict(list))
|
||||
for record in self.zone_records(zone):
|
||||
_type = record['type']
|
||||
if _type == 'SOA':
|
||||
if _type not in self.SUPPORTS:
|
||||
continue
|
||||
elif _type == 'TXT' and record['content'].startswith('ALIAS for'):
|
||||
# ALIAS has a "ride along" TXT record with 'ALIAS for XXXX',
|
||||
|
@@ -204,6 +204,8 @@ class Ns1Provider(BaseProvider):
|
||||
zone_hash = {}
|
||||
for record in chain(records, geo_records):
|
||||
_type = record['type']
|
||||
if _type not in self.SUPPORTS:
|
||||
continue
|
||||
data_for = getattr(self, '_data_for_{}'.format(_type))
|
||||
name = zone.hostname_from_fqdn(record['domain'])
|
||||
record = Record.new(zone, name, data_for(_type, record),
|
||||
|
@@ -257,6 +257,39 @@ class TestNs1Provider(TestCase):
|
||||
self.assertEquals(self.expected, zone.records)
|
||||
self.assertEquals(('unit.tests',), load_mock.call_args[0])
|
||||
|
||||
# Test skipping unsupported record type
|
||||
load_mock.reset_mock()
|
||||
nsone_zone = DummyZone(self.nsone_records + [{
|
||||
'type': 'UNSUPPORTED',
|
||||
'ttl': 42,
|
||||
'short_answers': ['unsupported'],
|
||||
'domain': 'unsupported.unit.tests.',
|
||||
}])
|
||||
load_mock.side_effect = [nsone_zone]
|
||||
zone_search = Mock()
|
||||
zone_search.return_value = [
|
||||
{
|
||||
"domain": "geo.unit.tests",
|
||||
"zone": "unit.tests",
|
||||
"type": "A",
|
||||
"answers": [
|
||||
{'answer': ['1.1.1.1'], 'meta': {}},
|
||||
{'answer': ['1.2.3.4'],
|
||||
'meta': {'ca_province': ['ON']}},
|
||||
{'answer': ['2.3.4.5'], 'meta': {'us_state': ['NY']}},
|
||||
{'answer': ['3.4.5.6'], 'meta': {'country': ['US']}},
|
||||
{'answer': ['4.5.6.7'],
|
||||
'meta': {'iso_region_code': ['NA-US-WA']}},
|
||||
],
|
||||
'ttl': 34,
|
||||
},
|
||||
]
|
||||
nsone_zone.search = zone_search
|
||||
zone = Zone('unit.tests.', [])
|
||||
provider.populate(zone)
|
||||
self.assertEquals(self.expected, zone.records)
|
||||
self.assertEquals(('unit.tests',), load_mock.call_args[0])
|
||||
|
||||
@patch('nsone.NSONE.createZone')
|
||||
@patch('nsone.NSONE.loadZone')
|
||||
def test_sync(self, load_mock, create_mock):
|
||||
|
Reference in New Issue
Block a user