Browse Source

Explicit list-ification

pull/384/head
Ross McFarland 6 years ago
parent
commit
ee0efc5b3a
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
4 changed files with 15 additions and 13 deletions
  1. +1
    -1
      octodns/provider/base.py
  2. +2
    -1
      octodns/provider/ovh.py
  3. +1
    -2
      octodns/yaml.py
  4. +11
    -9
      tests/test_octodns_provider_yaml.py

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

@ -60,7 +60,7 @@ class BaseProvider(BaseSource):
# allow the provider to filter out false positives
before = len(changes)
changes = filter(self._include_change, changes)
changes = list(filter(self._include_change, changes))
after = len(changes)
if before != after:
self.log.info('plan: filtered out %s changes', before - after)


+ 2
- 1
octodns/provider/ovh.py View File

@ -325,7 +325,8 @@ class OvhProvider(BaseProvider):
splitted = value.split('\\;')
found_key = False
for splitted_value in splitted:
sub_split = map(lambda x: x.strip(), splitted_value.split("=", 1))
sub_split = list(map(lambda x: x.strip(),
splitted_value.split("=", 1)))
if len(sub_split) < 2:
return False
key, value = sub_split[0], sub_split[1]


+ 1
- 2
octodns/yaml.py View File

@ -49,8 +49,7 @@ class SortingDumper(SafeDumper):
'''
def _representer(self, data):
data = data.items()
data.sort(key=lambda d: _natsort_key(d[0]))
data = sorted(data.items(), key=lambda d: _natsort_key(d[0]))
return self.represent_mapping(self.DEFAULT_MAPPING_TAG, data)


+ 11
- 9
tests/test_octodns_provider_yaml.py View File

@ -57,8 +57,9 @@ class TestYamlProvider(TestCase):
# We add everything
plan = target.plan(zone)
self.assertEquals(15, len(filter(lambda c: isinstance(c, Create),
plan.changes)))
self.assertEquals(15, len(list(filter(lambda c:
isinstance(c, Create),
plan.changes))))
self.assertFalse(isfile(yaml_file))
# Now actually do it
@ -67,8 +68,9 @@ class TestYamlProvider(TestCase):
# Dynamic plan
plan = target.plan(dynamic_zone)
self.assertEquals(5, len(filter(lambda c: isinstance(c, Create),
plan.changes)))
self.assertEquals(5, len(list(filter(lambda c:
isinstance(c, Create),
plan.changes))))
self.assertFalse(isfile(dynamic_yaml_file))
# Apply it
self.assertEquals(5, target.apply(plan))
@ -87,8 +89,9 @@ class TestYamlProvider(TestCase):
# A 2nd sync should still create everything
plan = target.plan(zone)
self.assertEquals(15, len(filter(lambda c: isinstance(c, Create),
plan.changes)))
self.assertEquals(15, len(list(filter(lambda c:
isinstance(c, Create),
plan.changes))))
with open(yaml_file) as fh:
data = safe_load(fh.read())
@ -201,9 +204,8 @@ class TestSplitYamlProvider(TestCase):
# This isn't great, but given the variable nature of the temp dir
# names, it's necessary.
self.assertItemsEqual(
yaml_files,
(basename(f) for f in _list_all_yaml_files(directory)))
d = list(basename(f) for f in _list_all_yaml_files(directory))
self.assertEqual(len(yaml_files), len(d))
def test_zone_directory(self):
source = SplitYamlProvider(


Loading…
Cancel
Save