Function volume_types.get_all_types returns dict, then
VolumeTypeList.get_all passes it to base.obj_make_list, which, in turn,
passes it to oslo_versionedobjects.base.obj_make_list.
And this function iterates over 4th argument and calls
item_cls._from_db_object for each item. So if it will iterate over dict
from volume_types.get_all_types, it'll get strings instead of orm
objects.
By the way, VolumeTypeList.get_all is not used anywhere in cinder code.
I tried to use it in unit test for my new patch and found this problem.
Closes-Bug: #
1505653
Change-Id: If789bc5bf224974de5c4e4b9a57c83ef51d1779b
types = volume_types.get_all_types(context, inactive, search_opts)
expected_attrs = ['extra_specs', 'projects']
return base.obj_make_list(context, cls(context),
- objects.VolumeType, types,
+ objects.VolumeType, types.values(),
expected_attrs=expected_attrs)
@mock.patch('cinder.volume.volume_types.get_all_types')
def test_get_all(self, get_all_types):
db_volume_type = fake_volume.fake_db_volume_type()
- get_all_types.return_value = [db_volume_type]
+ get_all_types.return_value = {db_volume_type['name']: db_volume_type}
volume_types = objects.VolumeTypeList.get_all(self.context)
self.assertEqual(1, len(volume_types))