Browse Source

Prepare tests with failing "managed subzone" error

The is not a zone between delegated.subzone.unit.tests. and unit.tests.,
however we get a delegated subzone error.  This modifies the tests to
succeed with the added record, however the tests fail as it incorrectly
throws the managed subzone error.

Change the name of delegated.subzone, and the tests will pass cleanly.
pull/908/head
Sachi King 4 years ago
parent
commit
e299ceced2
5 changed files with 23 additions and 11 deletions
  1. +5
    -0
      tests/config/simple.yaml
  2. +1
    -0
      tests/config/sub.txt.unit.tests.yaml
  3. +5
    -0
      tests/config/unit.tests.yaml
  4. +7
    -7
      tests/test_octodns_manager.py
  5. +5
    -4
      tests/test_octodns_provider_yaml.py

+ 5
- 0
tests/config/simple.yaml View File

@ -33,6 +33,11 @@ zones:
targets: targets:
- dump - dump
- dump2 - dump2
sub.txt.unit.tests.:
sources:
- in
targets:
- dump
empty.: empty.:
sources: sources:
- in - in


+ 1
- 0
tests/config/sub.txt.unit.tests.yaml View File

@ -0,0 +1 @@
---

+ 5
- 0
tests/config/unit.tests.yaml View File

@ -162,6 +162,11 @@ sub:
values: values:
- 6.2.3.4. - 6.2.3.4.
- 7.2.3.4. - 7.2.3.4.
sub.txt:
type: 'NS'
values:
- ns1.test.
- ns2.test.
txt: txt:
ttl: 600 ttl: 600
type: TXT type: TXT


+ 7
- 7
tests/test_octodns_manager.py View File

@ -121,12 +121,12 @@ class TestManager(TestCase):
environ['YAML_TMP_DIR'] = tmpdir.dirname environ['YAML_TMP_DIR'] = tmpdir.dirname
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
.sync(dry_run=False) .sync(dry_run=False)
self.assertEqual(26, tc)
self.assertEqual(27, tc)
# try with just one of the zones # try with just one of the zones
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
.sync(dry_run=False, eligible_zones=['unit.tests.']) .sync(dry_run=False, eligible_zones=['unit.tests.'])
self.assertEqual(20, tc)
self.assertEqual(21, tc)
# the subzone, with 2 targets # the subzone, with 2 targets
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
@ -141,18 +141,18 @@ class TestManager(TestCase):
# Again with force # Again with force
tc = Manager(get_config_filename('simple.yaml')) \ tc = Manager(get_config_filename('simple.yaml')) \
.sync(dry_run=False, force=True) .sync(dry_run=False, force=True)
self.assertEqual(26, tc)
self.assertEqual(27, tc)
# Again with max_workers = 1 # Again with max_workers = 1
tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \ tc = Manager(get_config_filename('simple.yaml'), max_workers=1) \
.sync(dry_run=False, force=True) .sync(dry_run=False, force=True)
self.assertEqual(26, tc)
self.assertEqual(27, tc)
# Include meta # Include meta
tc = Manager(get_config_filename('simple.yaml'), max_workers=1, tc = Manager(get_config_filename('simple.yaml'), max_workers=1,
include_meta=True) \ include_meta=True) \
.sync(dry_run=False, force=True) .sync(dry_run=False, force=True)
self.assertEqual(30, tc)
self.assertEqual(32, tc)
def test_eligible_sources(self): def test_eligible_sources(self):
with TemporaryDirectory() as tmpdir: with TemporaryDirectory() as tmpdir:
@ -220,13 +220,13 @@ class TestManager(TestCase):
# compare doesn't use _process_desired_zone and thus doesn't filter # compare doesn't use _process_desired_zone and thus doesn't filter
# out root NS records, that seems fine/desirable # out root NS records, that seems fine/desirable
changes = manager.compare(['in'], ['dump'], 'unit.tests.') changes = manager.compare(['in'], ['dump'], 'unit.tests.')
self.assertEqual(21, len(changes))
self.assertEqual(22, len(changes))
# Compound sources with varying support # Compound sources with varying support
changes = manager.compare(['in', 'nosshfp'], changes = manager.compare(['in', 'nosshfp'],
['dump'], ['dump'],
'unit.tests.') 'unit.tests.')
self.assertEqual(20, len(changes))
self.assertEqual(21, len(changes))
with self.assertRaises(ManagerException) as ctx: with self.assertRaises(ManagerException) as ctx:
manager.compare(['nope'], ['dump'], 'unit.tests.') manager.compare(['nope'], ['dump'], 'unit.tests.')


+ 5
- 4
tests/test_octodns_provider_yaml.py View File

@ -34,7 +34,7 @@ class TestYamlProvider(TestCase):
# without it we see everything # without it we see everything
source.populate(zone) source.populate(zone)
self.assertEqual(23, len(zone.records))
self.assertEqual(24, len(zone.records))
source.populate(dynamic_zone) source.populate(dynamic_zone)
self.assertEqual(6, len(dynamic_zone.records)) self.assertEqual(6, len(dynamic_zone.records))
@ -57,12 +57,12 @@ class TestYamlProvider(TestCase):
# We add everything # We add everything
plan = target.plan(zone) plan = target.plan(zone)
self.assertEqual(20, len([c for c in plan.changes
self.assertEqual(21, len([c for c in plan.changes
if isinstance(c, Create)])) if isinstance(c, Create)]))
self.assertFalse(isfile(yaml_file)) self.assertFalse(isfile(yaml_file))
# Now actually do it # Now actually do it
self.assertEqual(20, target.apply(plan))
self.assertEqual(21, target.apply(plan))
self.assertTrue(isfile(yaml_file)) self.assertTrue(isfile(yaml_file))
# Dynamic plan # Dynamic plan
@ -90,7 +90,7 @@ class TestYamlProvider(TestCase):
# A 2nd sync should still create everything # A 2nd sync should still create everything
plan = target.plan(zone) plan = target.plan(zone)
self.assertEqual(20, len([c for c in plan.changes
self.assertEqual(21, len([c for c in plan.changes
if isinstance(c, Create)])) if isinstance(c, Create)]))
with open(yaml_file) as fh: with open(yaml_file) as fh:
@ -111,6 +111,7 @@ class TestYamlProvider(TestCase):
self.assertTrue('values' in data.pop('txt')) self.assertTrue('values' in data.pop('txt'))
self.assertTrue('values' in data.pop('loc')) self.assertTrue('values' in data.pop('loc'))
self.assertTrue('values' in data.pop('urlfwd')) self.assertTrue('values' in data.pop('urlfwd'))
self.assertTrue('values' in data.pop('sub.txt'))
# these are stored as singular 'value' # these are stored as singular 'value'
self.assertTrue('value' in data.pop('_imap._tcp')) self.assertTrue('value' in data.pop('_imap._tcp'))
self.assertTrue('value' in data.pop('_pop3._tcp')) self.assertTrue('value' in data.pop('_pop3._tcp'))


Loading…
Cancel
Save