Browse Source

Improve leneience logic comment, further test cases

pull/1300/head
Ross McFarland 3 months ago
parent
commit
30dd61dcd0
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 29 additions and 1 deletions
  1. +1
    -1
      octodns/zone.py
  2. +28
    -0
      tests/test_octodns_zone.py

+ 1
- 1
octodns/zone.py View File

@ -199,7 +199,7 @@ class Zone(object):
not lenient
# existing and new records aren't lenient
and not (existing_lenient and new_lenient)
# new record or ecisting record are a CNAME
# and there'll be a CNAME co-existing with other records
and (
(record._type == 'CNAME' and len(node) > 0)
or ('CNAME' in [r._type for r in node])


+ 28
- 0
tests/test_octodns_zone.py View File

@ -561,6 +561,34 @@ class TestZone(TestCase):
zone.add_record(a)
self.assertEqual(set([a, cname]), zone.records)
# adding something else w/o lenient still errors
zone = Zone('unit.tests.', [])
zone.add_record(cname)
zone.add_record(a)
txt = Record.new(
zone, 'www', {'ttl': 60, 'type': 'TXT', 'value': 'Hello World'}
)
with self.assertRaises(InvalidNodeException):
zone.add_record(txt)
self.assertEqual(set([a, cname]), zone.records)
# if the 3rd record is lenient it can be added
zone = Zone('unit.tests.', [])
zone.add_record(cname)
zone.add_record(a)
txt = Record.new(
zone,
'www',
{
'ttl': 60,
'type': 'TXT',
'value': 'Hello World',
'octodns': {'lenient': True},
},
)
zone.add_record(txt)
self.assertEqual(set([a, cname, txt]), zone.records)
def test_excluded_records(self):
zone_normal = Zone('unit.tests.', [])
zone_excluded = Zone('unit.tests.', [])


Loading…
Cancel
Save