Merge "Removing duplicates from columns_to_join list"
This commit is contained in:
commit
11fd1470d3
@ -88,7 +88,13 @@ def _expected_cols(expected_attrs):
|
||||
if complex_cols:
|
||||
simple_cols.append('extra')
|
||||
simple_cols = [x for x in simple_cols if x not in _INSTANCE_EXTRA_FIELDS]
|
||||
return simple_cols + complex_cols
|
||||
expected_cols = simple_cols + complex_cols
|
||||
# NOTE(pumaranikar): expected_cols list can contain duplicates since
|
||||
# caller appends column attributes to expected_attr without checking if
|
||||
# it is already present in the list or not. Hence, we remove duplicates
|
||||
# here, if any. The resultant list is sorted based on list index to
|
||||
# maintain the insertion order.
|
||||
return sorted(list(set(expected_cols)), key=expected_cols.index)
|
||||
|
||||
|
||||
_NO_DATA_SENTINEL = object()
|
||||
|
@ -1877,6 +1877,18 @@ class TestInstanceObjectMisc(test.TestCase):
|
||||
instance._expected_cols(['metadata',
|
||||
'numa_topology']))
|
||||
|
||||
def test_expected_cols_no_duplicates(self):
|
||||
expected_attr = ['metadata', 'system_metadata', 'info_cache',
|
||||
'security_groups', 'info_cache', 'metadata',
|
||||
'pci_devices', 'tags', 'extra', 'flavor']
|
||||
|
||||
result_list = instance._expected_cols(expected_attr)
|
||||
|
||||
self.assertEqual(len(result_list), len(set(expected_attr)))
|
||||
self.assertEqual(['metadata', 'system_metadata', 'info_cache',
|
||||
'security_groups', 'pci_devices', 'tags', 'extra',
|
||||
'extra.flavor'], result_list)
|
||||
|
||||
def test_migrate_instance_keypairs(self):
|
||||
ctxt = context.RequestContext('foo', 'bar')
|
||||
key = objects.KeyPair(context=ctxt,
|
||||
|
Loading…
Reference in New Issue
Block a user