Browse Source

Include record_type in change data

pull/1178/head
Ross McFarland 2 years ago
parent
commit
3f7af27537
No known key found for this signature in database GPG Key ID: 943B179E15D3B22A
2 changed files with 21 additions and 5 deletions
  1. +11
    -2
      octodns/record/change.py
  2. +10
    -3
      tests/test_octodns_plan.py

+ 11
- 2
octodns/record/change.py View File

@ -27,7 +27,11 @@ class Create(Change):
@property
def data(self):
return {'type': 'create', 'new': self.new.data}
return {
'type': 'create',
'new': self.new.data,
'record_type': self.new._type,
}
def __repr__(self, leader=''):
source = self.new.source.id if self.new.source else ''
@ -43,6 +47,7 @@ class Update(Change):
'type': 'update',
'existing': self.existing.data,
'new': self.new.data,
'record_type': self.new._type,
}
# Leader is just to allow us to work around heven eating leading whitespace
@ -65,7 +70,11 @@ class Delete(Change):
@property
def data(self):
return {'type': 'delete', 'existing': self.existing.data}
return {
'type': 'delete',
'existing': self.existing.data,
'record_type': self.existing._type,
}
def __repr__(self, leader=''):
return f'Delete {self.existing}'

+ 10
- 3
tests/test_octodns_plan.py View File

@ -407,18 +407,25 @@ class TestPlanSafety(TestCase):
# we'll test the change .data's here while we're at it since they don't
# have a dedicated test (file)
delete_data = data['changes'][0] # delete
self.assertEqual(['existing', 'type'], sorted(delete_data.keys()))
self.assertEqual(
['existing', 'record_type', 'type'], sorted(delete_data.keys())
)
self.assertEqual('delete', delete_data['type'])
self.assertEqual('A', delete_data['record_type'])
self.assertEqual(delete.existing.data, delete_data['existing'])
create_data = data['changes'][1] # create
self.assertEqual(['new', 'type'], sorted(create_data.keys()))
self.assertEqual(
['new', 'record_type', 'type'], sorted(create_data.keys())
)
self.assertEqual('create', create_data['type'])
self.assertEqual('CNAME', create_data['record_type'])
self.assertEqual(create.new.data, create_data['new'])
update_data = data['changes'][3] # update
self.assertEqual(
['existing', 'new', 'type'], sorted(update_data.keys())
['existing', 'new', 'record_type', 'type'],
sorted(update_data.keys()),
)
self.assertEqual('update', update_data['type'])
self.assertEqual(update.existing.data, update_data['existing'])


Loading…
Cancel
Save