Browse Source

Tests for new-style ns1 data_for_dynamic_A fallback only pools

pull/699/head
Ross McFarland 5 years ago
parent
commit
fbd8389903
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 110 additions and 1 deletions
  1. +1
    -1
      octodns/provider/ns1.py
  2. +109
    -0
      tests/test_octodns_provider_ns1.py

+ 1
- 1
octodns/provider/ns1.py View File

@ -542,7 +542,7 @@ class Ns1Provider(BaseProvider):
rules[rule_order] = rule
# The group notes field in the UI is a `note` on the region here,
# that's where we can find our pool's fallback.
# that's where we can find our pool's fallback in < v0.9.11 anyway
if 'fallback' in notes:
# set the fallback pool name
pools[pool_name]['fallback'] = notes['fallback']


+ 109
- 0
tests/test_octodns_provider_ns1.py View File

@ -1478,6 +1478,115 @@ class TestNs1ProviderDynamic(TestCase):
self.assertTrue(
'OC-{}'.format(c) in data4['dynamic']['rules'][0]['geos'])
# Test out fallback only pools and new-style notes
ns1_record = {
'answers': [{
'answer': ['1.1.1.1'],
'meta': {
'priority': 1,
'note': 'from:one__country pool:one fallback:two',
},
'region': 'one_country',
}, {
'answer': ['2.2.2.2'],
'meta': {
'priority': 2,
'note': 'from:one__country pool:two fallback:three',
},
'region': 'one_country',
}, {
'answer': ['3.3.3.3'],
'meta': {
'priority': 3,
'note': 'from:one__country pool:three fallback:',
},
'region': 'one_country',
}, {
'answer': ['5.5.5.5'],
'meta': {
'priority': 4,
'note': 'from:--default--',
},
'region': 'one_country',
}, {
'answer': ['4.4.4.4'],
'meta': {
'priority': 1,
'note': 'from:four__country pool:four fallback:',
},
'region': 'four_country',
}, {
'answer': ['5.5.5.5'],
'meta': {
'priority': 2,
'note': 'from:--default--',
},
'region': 'four_country',
}],
'domain': 'unit.tests',
'filters': filters,
'regions': {
'one__country': {
'meta': {
'note': 'rule-order:1 fallback:two',
'country': ['CA'],
'us_state': ['OR'],
},
},
'four__country': {
'meta': {
'note': 'rule-order:2',
'country': ['CA'],
'us_state': ['OR'],
},
},
catchall_pool_name: {
'meta': {
'note': 'rule-order:3',
},
}
},
'tier': 3,
'ttl': 42,
}
data = provider._data_for_dynamic_A('A', ns1_record)
self.assertEquals({
'dynamic': {
'pools': {
'four': {
'fallback': None,
'values': [{'value': '4.4.4.4', 'weight': 1}]
},
'one': {
'fallback': 'two',
'values': [{'value': '1.1.1.1', 'weight': 1}]
},
'three': {
'fallback': None,
'values': [{'value': '3.3.3.3', 'weight': 1}]
},
'two': {
'fallback': 'three',
'values': [{'value': '2.2.2.2', 'weight': 1}]
},
},
'rules': [{
'_order': '1',
'geos': ['NA-CA', 'NA-US-OR'],
'pool': 'one'
}, {
'_order': '2',
'geos': ['NA-CA', 'NA-US-OR'],
'pool': 'four'
}, {
'_order': '3', 'pool': 'iad'}
]
},
'ttl': 42,
'type': 'A',
'values': ['5.5.5.5']
}, data)
@patch('ns1.rest.records.Records.retrieve')
@patch('ns1.rest.zones.Zones.retrieve')
@patch('octodns.provider.ns1.Ns1Provider._monitors_for')


Loading…
Cancel
Save