Browse Source

Add tests for Manager.get_zones()

pull/592/head
Jonathan Leroy 5 years ago
parent
commit
897a033443
No known key found for this signature in database GPG Key ID: 7A0BCBE3934842EA
2 changed files with 16 additions and 4 deletions
  1. +2
    -2
      octodns/manager.py
  2. +14
    -2
      tests/test_octodns_manager.py

+ 2
- 2
octodns/manager.py View File

@ -469,8 +469,8 @@ class Manager(object):
def get_zone(self, zone_name):
if not zone_name[-1] == '.':
raise Exception('Invalid zone name {}, missing ending dot'
.format(zone_name))
raise ManagerException('Invalid zone name {}, missing ending dot'
.format(zone_name))
for name, config in self.config['zones'].items():
if name == zone_name:


+ 14
- 2
tests/test_octodns_manager.py View File

@ -286,6 +286,18 @@ class TestManager(TestCase):
.validate_configs()
self.assertTrue('unknown source' in text_type(ctx.exception))
def test_get_zone(self):
Manager(get_config_filename('simple.yaml')).get_zone('unit.tests.')
with self.assertRaises(ManagerException) as ctx:
Manager(get_config_filename('simple.yaml')).get_zone('unit.tests')
self.assertTrue('missing ending dot' in text_type(ctx.exception))
with self.assertRaises(ManagerException) as ctx:
Manager(get_config_filename('simple.yaml')) \
.get_zone('unknown-zone.tests.')
self.assertTrue('Unknown zone name' in text_type(ctx.exception))
def test_populate_lenient_fallback(self):
with TemporaryDirectory() as tmpdir:
environ['YAML_TMP_DIR'] = tmpdir.dirname
@ -321,8 +333,8 @@ class TestManager(TestCase):
with self.assertRaises(ManagerException) as ctx:
Manager(get_config_filename('unknown-source-zone.yaml')) \
.validate_configs()
self.assertTrue('Invalid alias zone' in
text_type(ctx.exception))
self.assertTrue('Invalid alias zone' in
text_type(ctx.exception))
class TestMainThreadExecutor(TestCase):


Loading…
Cancel
Save