Merge "Revert 372057bddb27716acd42a88591552a8dee7b519b"

This commit is contained in:
Jenkins 2016-08-03 14:27:32 +00:00 committed by Gerrit Code Review
commit a841997008
2 changed files with 3 additions and 71 deletions

View File

@ -105,18 +105,13 @@ class RecordSetAPIv2Adapter(base.APIv2Adapter):
del new_recordset['records']
# Remove deleted records if we have provided a records array
new_recordset_records = objects.RecordList()
if record_update:
for record in recordset.records:
if record.data not in records_to_rm:
new_recordset_records.append(record)
recordset.records[:] = [record for record in recordset.records
if record.data not in records_to_rm]
# Add new records
for record in records_to_add:
new_recordset_records.append(objects.Record(data=record))
# Do a single assignment, preserves the object change fields
recordset.records = new_recordset_records
recordset.records.append(objects.Record(data=record))
return super(RecordSetAPIv2Adapter, cls)._parse_object(
new_recordset, recordset, *args, **kwargs)

View File

@ -23,7 +23,6 @@ import oslotest.base
import testtools
from designate import exceptions
from designate.objects.adapters import DesignateAdapter
from designate import objects
LOG = logging.getLogger(__name__)
@ -193,65 +192,3 @@ class RecordSetTest(oslotest.base.BaseTestCase):
with testtools.ExpectedException(exceptions.InvalidObject):
# TODO(Federico): check the attributes of the exception
rs.validate()
def test_parse_rrset_object_preserves_changes(self):
old_ip = '1.1.1.1'
new_ip = '8.8.8.8'
original_records = objects.RecordList(
objects=[
objects.Record(data=old_ip),
]
)
rs = objects.RecordSet(
name='www.example.org.', type='A',
records=original_records
)
body = {
'records': [
new_ip
]
}
rs = DesignateAdapter.parse('API_v2', body, rs)
self.assertIn('records', rs.obj_what_changed())
def get_data(record_list):
return set([r.data for r in record_list])
self.assertEqual(set([old_ip]),
get_data(rs.obj_get_original_value('records')))
self.assertEqual(set([new_ip]),
get_data(rs.obj_get_changes()['records']))
def test_parse_rrset_object_preserves_changes_multiple_rrs(self):
old_ips = ['1.1.1.1', '2.2.2.2']
new_ips = ['2.2.2.2', '8.8.8.8']
original_records = objects.RecordList(
objects=[
objects.Record(data=ip) for ip in old_ips
]
)
rs = objects.RecordSet(
name='www.example.org.', type='A',
records=original_records
)
body = {
'records': new_ips
}
rs = DesignateAdapter.parse('API_v2', body, rs)
self.assertIn('records', rs.obj_what_changed())
def get_data(record_list):
return set([r.data for r in record_list])
self.assertEqual(set(old_ips),
get_data(rs.obj_get_original_value('records')))
self.assertEqual(set(new_ips),
get_data(rs.obj_get_changes()['records']))