mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Testing of (Split)YamlProvider.list_zones w/fixes
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
tests/config/split/other.thing/.gitkeep
Normal file
0
tests/config/split/other.thing/.gitkeep
Normal 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):
|
||||
|
||||
Reference in New Issue
Block a user