Fix bug with Record.copy when values is an empty list []

This commit is contained in:
Ross McFarland
2023-11-28 16:27:02 -08:00
parent 201d2c2423
commit 6f6cb79854
3 changed files with 19 additions and 5 deletions
+1
View File
@@ -1,6 +1,7 @@
## v1.?.0 - 2023-??-?? -
* Record.lenient property added similar to other common/standard _octodns data
* Fix bug with Record.copy when values is an empty list []
## v1.3.0 - 2023-11-14 - New and improved processors
+4 -1
View File
@@ -296,7 +296,10 @@ class ValuesMixin(object):
try:
values = data['values']
except KeyError:
values = [data['value']]
try:
values = [data['value']]
except KeyError:
values = []
self.values = sorted(self._value_type.process(values))
def changes(self, other, target):
+14 -4
View File
@@ -338,6 +338,17 @@ class TestRecord(TestCase):
del b._octodns['key']['second']
self.assertNotEqual(a.data, b.data)
def test_record_copy_with_no_values(self):
txt = Record.new(
self.zone,
'txt',
{'ttl': 45, 'type': 'TXT', 'values': []},
lenient=True,
)
dup = txt.copy()
self.assertEqual(txt.values, dup.values)
def test_change(self):
existing = Record.new(
self.zone, 'txt', {'ttl': 44, 'type': 'TXT', 'value': 'some text'}
@@ -631,10 +642,9 @@ class TestRecordValidation(TestCase):
lenient=True,
)
# __init__ may still blow up, even if validation is lenient
with self.assertRaises(KeyError) as ctx:
Record.new(self.zone, 'www', {'type': 'A', 'ttl': -1}, lenient=True)
self.assertEqual(('value',), ctx.exception.args)
# empty values is allowed with lenient
r = Record.new(self.zone, 'www', {'type': 'A', 'ttl': -1}, lenient=True)
self.assertEqual([], r.values)
# no exception if we're in lenient mode from config
Record.new(