mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Merge branch 'master' into gandi-provider
This commit is contained in:
21
tests/config/alias-zone-loop.yaml
Normal file
21
tests/config/alias-zone-loop.yaml
Normal file
@@ -0,0 +1,21 @@
|
||||
manager:
|
||||
max_workers: 2
|
||||
providers:
|
||||
in:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: tests/config
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
zones:
|
||||
unit.tests.:
|
||||
sources:
|
||||
- in
|
||||
targets:
|
||||
- dump
|
||||
|
||||
alias.tests.:
|
||||
alias: unit.tests.
|
||||
|
||||
alias-loop.tests.:
|
||||
alias: alias.tests.
|
||||
19
tests/config/simple-alias-zone.yaml
Normal file
19
tests/config/simple-alias-zone.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
manager:
|
||||
max_workers: 2
|
||||
providers:
|
||||
in:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: tests/config
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
zones:
|
||||
unit.tests.:
|
||||
sources:
|
||||
- in
|
||||
targets:
|
||||
- dump
|
||||
|
||||
alias.tests.:
|
||||
alias: unit.tests.
|
||||
|
||||
18
tests/config/unknown-source-zone.yaml
Normal file
18
tests/config/unknown-source-zone.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
manager:
|
||||
max_workers: 2
|
||||
providers:
|
||||
in:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: tests/config
|
||||
dump:
|
||||
class: octodns.provider.yaml.YamlProvider
|
||||
directory: env/YAML_TMP_DIR
|
||||
zones:
|
||||
unit.tests.:
|
||||
sources:
|
||||
- in
|
||||
targets:
|
||||
- dump
|
||||
|
||||
alias.tests.:
|
||||
alias: does-not-exists.tests.
|
||||
@@ -167,6 +167,30 @@ class TestManager(TestCase):
|
||||
.sync(eligible_targets=['foo'])
|
||||
self.assertEquals(0, tc)
|
||||
|
||||
def test_aliases(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
environ['YAML_TMP_DIR'] = tmpdir.dirname
|
||||
# Alias zones with a valid target.
|
||||
tc = Manager(get_config_filename('simple-alias-zone.yaml')) \
|
||||
.sync()
|
||||
self.assertEquals(0, tc)
|
||||
|
||||
# Alias zone with an invalid target.
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
tc = Manager(get_config_filename('unknown-source-zone.yaml')) \
|
||||
.sync()
|
||||
self.assertEquals('Invalid alias zone alias.tests.: source zone '
|
||||
'does-not-exists.tests. does not exist',
|
||||
text_type(ctx.exception))
|
||||
|
||||
# Alias zone that points to another alias zone.
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
tc = Manager(get_config_filename('alias-zone-loop.yaml')) \
|
||||
.sync()
|
||||
self.assertEquals('Invalid alias zone alias-loop.tests.: source '
|
||||
'zone alias.tests. is an alias zone',
|
||||
text_type(ctx.exception))
|
||||
|
||||
def test_compare(self):
|
||||
with TemporaryDirectory() as tmpdir:
|
||||
environ['YAML_TMP_DIR'] = tmpdir.dirname
|
||||
@@ -286,6 +310,36 @@ class TestManager(TestCase):
|
||||
.validate_configs()
|
||||
self.assertTrue('unknown source' in text_type(ctx.exception))
|
||||
|
||||
# Alias zone using an invalid source zone.
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('unknown-source-zone.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('does not exist' in
|
||||
text_type(ctx.exception))
|
||||
|
||||
# Alias zone that points to another alias zone.
|
||||
with self.assertRaises(ManagerException) as ctx:
|
||||
Manager(get_config_filename('alias-zone-loop.yaml')) \
|
||||
.validate_configs()
|
||||
self.assertTrue('is an alias zone' in
|
||||
text_type(ctx.exception))
|
||||
|
||||
# Valid config file using an alias zone.
|
||||
Manager(get_config_filename('simple-alias-zone.yaml')) \
|
||||
.validate_configs()
|
||||
|
||||
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
|
||||
|
||||
@@ -813,6 +813,39 @@ class TestRecord(TestCase):
|
||||
})
|
||||
self.assertTrue('Unknown record type' in text_type(ctx.exception))
|
||||
|
||||
def test_record_copy(self):
|
||||
a = Record.new(self.zone, 'a', {
|
||||
'ttl': 44,
|
||||
'type': 'A',
|
||||
'value': '1.2.3.4',
|
||||
})
|
||||
|
||||
# Identical copy.
|
||||
b = a.copy()
|
||||
self.assertIsInstance(b, ARecord)
|
||||
self.assertEquals('unit.tests.', b.zone.name)
|
||||
self.assertEquals('a', b.name)
|
||||
self.assertEquals('A', b._type)
|
||||
self.assertEquals(['1.2.3.4'], b.values)
|
||||
|
||||
# Copy with another zone object.
|
||||
c_zone = Zone('other.tests.', [])
|
||||
c = a.copy(c_zone)
|
||||
self.assertIsInstance(c, ARecord)
|
||||
self.assertEquals('other.tests.', c.zone.name)
|
||||
self.assertEquals('a', c.name)
|
||||
self.assertEquals('A', c._type)
|
||||
self.assertEquals(['1.2.3.4'], c.values)
|
||||
|
||||
# Record with no record type specified in data.
|
||||
d_data = {
|
||||
'ttl': 600,
|
||||
'values': ['just a test']
|
||||
}
|
||||
d = TxtRecord(self.zone, 'txt', d_data)
|
||||
d.copy()
|
||||
self.assertEquals('TXT', d._type)
|
||||
|
||||
def test_change(self):
|
||||
existing = Record.new(self.zone, 'txt', {
|
||||
'ttl': 44,
|
||||
|
||||
Reference in New Issue
Block a user