Browse Source

Testing of (Split)YamlProvider.list_zones w/fixes

pull/1026/head
Ross McFarland 2 years ago
parent
commit
92623b1a2c
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
4 changed files with 36 additions and 3 deletions
  1. +1
    -2
      octodns/manager.py
  2. +8
    -1
      octodns/provider/yaml.py
  3. +0
    -0
      tests/config/split/other.thing/.gitkeep
  4. +27
    -0
      tests/test_octodns_provider_yaml.py

+ 1
- 2
octodns/manager.py View File

@ -528,8 +528,7 @@ class Manager(object):
for source in sources:
if not hasattr(source, 'list_zones'):
raise ManagerException(
f'dynamic zone=%s includes a source that does not support `list_zones`',
name,
f'dynamic zone={name} includes a source that does not support `list_zones`',
)
for zone_name in source.list_zones():
if zone_name in zones:


+ 8
- 1
octodns/provider/yaml.py View File

@ -192,7 +192,7 @@ class YamlProvider(BaseProvider):
def list_zones(self):
for filename in listdir(self.directory):
if not filename.endswith('.yaml'):
if not filename.endswith('.yaml') or filename.count('.') < 2:
continue
yield filename[:-4]
@ -330,6 +330,13 @@ class SplitYamlProvider(YamlProvider):
filename = f'{zone.name[:-1]}{self.extension}'
return join(self.directory, filename)
def list_zones(self):
n = len(self.extension) - 1
for filename in listdir(self.directory):
if not filename.endswith(self.extension):
continue
yield filename[:-n]
def populate(self, zone, target=False, lenient=False):
self.log.debug(
'populate: name=%s, target=%s, lenient=%s',


+ 0
- 0
tests/config/split/other.thing/.gitkeep View File


+ 27
- 0
tests/test_octodns_provider_yaml.py View File

@ -296,6 +296,18 @@ xn--dj-kia8a:
self.assertTrue(source.supports(DummyType(source)))
self.assertTrue(source.supports(DummyType(self)))
def test_list_zones(self):
provider = YamlProvider('test', 'tests/config')
self.assertEqual(
[
'dynamic.tests.',
'sub.txt.unit.tests.',
'subzone.unit.tests.',
'unit.tests.',
],
sorted(provider.list_zones()),
)
class TestSplitYamlProvider(TestCase):
def test_list_all_yaml_files(self):
@ -570,6 +582,21 @@ class TestSplitYamlProvider(TestCase):
)
self.assertEqual(source.supports_root_ns, copy.supports_root_ns)
def test_list_zones(self):
provider = SplitYamlProvider(
'test', 'tests/config/split', extension='.tst'
)
self.assertEqual(
[
'dynamic.tests.',
'empty.',
'subzone.unit.tests.',
'unit.tests.',
'unordered.',
],
sorted(provider.list_zones()),
)
class TestOverridingYamlProvider(TestCase):
def test_provider(self):


Loading…
Cancel
Save