Browse Source

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

pull/1111/head
Ross McFarland 2 years ago
parent
commit
03f37e3ae9
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
3 changed files with 19 additions and 5 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +4
    -1
      octodns/record/base.py
  3. +14
    -4
      tests/test_octodns_record.py

+ 1
- 0
CHANGELOG.md 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


+ 4
- 1
octodns/record/base.py 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
tests/test_octodns_record.py 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(


Loading…
Cancel
Save