Browse Source

Merge pull request #574 from github/fix-populate-lenient

lenient param to populate needs to be optoinal
pull/575/head
Ross McFarland 6 years ago
committed by GitHub
parent
commit
817e8bc8bd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions
  1. +9
    -1
      octodns/manager.py
  2. +23
    -0
      tests/test_octodns_manager.py

+ 9
- 1
octodns/manager.py View File

@ -8,6 +8,7 @@ from __future__ import absolute_import, division, print_function, \
from concurrent.futures import ThreadPoolExecutor
from importlib import import_module
from os import environ
from six import text_type
import logging
from .provider.base import BaseProvider
@ -228,7 +229,14 @@ class Manager(object):
zone = Zone(zone_name,
sub_zones=self.configured_sub_zones(zone_name))
for source in sources:
source.populate(zone, lenient=lenient)
try:
source.populate(zone, lenient=lenient)
except TypeError as e:
if "keyword argument 'lenient'" not in text_type(e):
raise
self.log.warn(': provider %s does not accept lenient param',
source.__class__.__name__)
source.populate(zone)
self.log.debug('sync: planning, zone=%s', zone_name)
plans = []


+ 23
- 0
tests/test_octodns_manager.py View File

@ -278,6 +278,29 @@ class TestManager(TestCase):
.validate_configs()
self.assertTrue('unknown source' in text_type(ctx.exception))
def test_populate_lenient_fallback(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
# Only allow a target that doesn't exist
manager = Manager(get_config_filename('simple.yaml'))
class NoLenient(SimpleProvider):
def populate(self, zone, source=False):
pass
# This should be ok, we'll fall back to not passing it
manager._populate_and_plan('unit.tests.', [NoLenient()], [])
class NoZone(SimpleProvider):
def populate(self, lenient=False):
pass
# This will blow up, we don't fallback for source
with self.assertRaises(TypeError):
manager._populate_and_plan('unit.tests.', [NoZone()], [])
class TestMainThreadExecutor(TestCase):


Loading…
Cancel
Save