Merge "Remove "list_volume" from filter" into stable/ocata
This commit is contained in:
commit
8eda0ba793
|
@ -165,6 +165,8 @@ class GroupsController(wsgi.Controller):
|
|||
marker, limit, offset = common.get_pagination_params(filters)
|
||||
sort_keys, sort_dirs = common.get_sort_params(filters)
|
||||
|
||||
filters.pop('list_volume', None)
|
||||
|
||||
groups = self.group_api.get_all(
|
||||
context, filters=filters, marker=marker, limit=limit,
|
||||
offset=offset, sort_keys=sort_keys, sort_dirs=sort_dirs)
|
||||
|
|
|
@ -144,6 +144,49 @@ class GroupsAPITestCase(test.TestCase):
|
|||
self.assertEqual([fake.VOLUME_TYPE_ID],
|
||||
res_dict['group']['volume_types'])
|
||||
|
||||
@ddt.data(('3.24', False), ('3.24', True), ('3.25', False), ('3.25', True))
|
||||
@ddt.unpack
|
||||
@mock.patch('cinder.objects.volume_type.VolumeTypeList.get_all_by_group')
|
||||
@mock.patch('cinder.objects.volume.VolumeList.get_all_by_generic_group')
|
||||
def test_list_group_with_list_volume(self, version, has_list_volume,
|
||||
mock_vol_get_all_by_group,
|
||||
mock_vol_type_get_all_by_group):
|
||||
volume_objs = [objects.Volume(context=self.ctxt, id=i)
|
||||
for i in [fake.VOLUME_ID]]
|
||||
volumes = objects.VolumeList(context=self.ctxt, objects=volume_objs)
|
||||
mock_vol_get_all_by_group.return_value = volumes
|
||||
|
||||
vol_type_objs = [objects.VolumeType(context=self.ctxt, id=i)
|
||||
for i in [fake.VOLUME_TYPE_ID]]
|
||||
vol_types = objects.VolumeTypeList(context=self.ctxt,
|
||||
objects=vol_type_objs)
|
||||
mock_vol_type_get_all_by_group.return_value = vol_types
|
||||
|
||||
if has_list_volume:
|
||||
req = fakes.HTTPRequest.blank(
|
||||
'/v3/%s/groups/detail?list_volume=True' % fake.PROJECT_ID,
|
||||
version=version)
|
||||
else:
|
||||
req = fakes.HTTPRequest.blank('/v3/%s/groups/detail' %
|
||||
fake.PROJECT_ID,
|
||||
version=version)
|
||||
res_dict = self.controller.detail(req)
|
||||
|
||||
# If the microversion >= 3.25 and "list_volume=True", "volumes" should
|
||||
# be contained in the response body. Else,"volumes" should not be
|
||||
# contained in the response body.
|
||||
self.assertEqual(3, len(res_dict['groups']))
|
||||
if (version, has_list_volume) == ('3.25', True):
|
||||
self.assertEqual([fake.VOLUME_ID],
|
||||
res_dict['groups'][0]['volumes'])
|
||||
else:
|
||||
self.assertIsNone(res_dict['groups'][0].get('volumes', None))
|
||||
|
||||
# "volumes" should not be contained in the response body when list
|
||||
# groups without detail.
|
||||
res_dict = self.controller.index(req)
|
||||
self.assertIsNone(res_dict['groups'][0].get('volumes', None))
|
||||
|
||||
@mock.patch('cinder.objects.volume_type.VolumeTypeList.get_all_by_group')
|
||||
@mock.patch('cinder.objects.volume.VolumeList.get_all_by_generic_group')
|
||||
def test_show_group_with_list_volume(self, mock_vol_get_all_by_group,
|
||||
|
|
Loading…
Reference in New Issue