1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

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 e612e2b885
commit 03f37e3ae9
3 changed files with 19 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
desired and/or existing zones just prior to computing changes.
* Fix an issue in MetaProcessor/Manager.include_meta where include_provider
wasn't correctly taking effect
* Fix bug with Record.copy when values is an empty list []
## v1.3.0 - 2023-11-14 - New and improved processors

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):

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(