Merge "Add show_nested parameter to GET v1/stacks API"
This commit is contained in:
commit
d6509849ba
@ -164,6 +164,7 @@ class StackController(object):
|
||||
'sort_dir': 'single',
|
||||
'sort_keys': 'multi',
|
||||
'show_deleted': 'single',
|
||||
'show_nested': 'single',
|
||||
}
|
||||
params = util.get_allowed_params(req.params, whitelist)
|
||||
filter_params = util.get_allowed_params(req.params, filter_whitelist)
|
||||
@ -173,6 +174,11 @@ class StackController(object):
|
||||
params[engine_api.PARAM_SHOW_DELETED] = param_utils.extract_bool(
|
||||
params[engine_api.PARAM_SHOW_DELETED])
|
||||
show_deleted = params[engine_api.PARAM_SHOW_DELETED]
|
||||
show_nested = False
|
||||
if engine_api.PARAM_SHOW_NESTED in params:
|
||||
params[engine_api.PARAM_SHOW_NESTED] = param_utils.extract_bool(
|
||||
params[engine_api.PARAM_SHOW_NESTED])
|
||||
show_nested = params[engine_api.PARAM_SHOW_NESTED]
|
||||
# get the with_count value, if invalid, raise ValueError
|
||||
with_count = False
|
||||
if req.params.get('with_count'):
|
||||
@ -195,7 +201,8 @@ class StackController(object):
|
||||
count = self.rpc_client.count_stacks(req.context,
|
||||
filters=filter_params,
|
||||
tenant_safe=tenant_safe,
|
||||
show_deleted=show_deleted)
|
||||
show_deleted=show_deleted,
|
||||
show_nested=show_nested)
|
||||
except AttributeError as exc:
|
||||
LOG.warning(_("Old Engine Version: %s") % exc)
|
||||
|
||||
|
@ -519,7 +519,7 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
tenant_safe=True,
|
||||
show_deleted=False)
|
||||
|
||||
def test_global_index_show_deleted_True(self, mock_enforce):
|
||||
def test_global_index_show_deleted_true(self, mock_enforce):
|
||||
rpc_client = self.controller.rpc_client
|
||||
rpc_client.list_stacks = mock.Mock(return_value=[])
|
||||
rpc_client.count_stacks = mock.Mock()
|
||||
@ -532,6 +532,32 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
tenant_safe=True,
|
||||
show_deleted=True)
|
||||
|
||||
def test_global_index_show_nested_false(self, mock_enforce):
|
||||
rpc_client = self.controller.rpc_client
|
||||
rpc_client.list_stacks = mock.Mock(return_value=[])
|
||||
rpc_client.count_stacks = mock.Mock()
|
||||
|
||||
params = {'show_nested': 'False'}
|
||||
req = self._get('/stacks', params=params)
|
||||
self.controller.index(req, tenant_id=self.tenant)
|
||||
rpc_client.list_stacks.assert_called_once_with(mock.ANY,
|
||||
filters=mock.ANY,
|
||||
tenant_safe=True,
|
||||
show_nested=False)
|
||||
|
||||
def test_global_index_show_nested_true(self, mock_enforce):
|
||||
rpc_client = self.controller.rpc_client
|
||||
rpc_client.list_stacks = mock.Mock(return_value=[])
|
||||
rpc_client.count_stacks = mock.Mock()
|
||||
|
||||
params = {'show_nested': 'True'}
|
||||
req = self._get('/stacks', params=params)
|
||||
self.controller.index(req, tenant_id=self.tenant)
|
||||
rpc_client.list_stacks.assert_called_once_with(mock.ANY,
|
||||
filters=mock.ANY,
|
||||
tenant_safe=True,
|
||||
show_nested=True)
|
||||
|
||||
def test_index_show_deleted_True_with_count_True(self, mock_enforce):
|
||||
rpc_client = self.controller.rpc_client
|
||||
rpc_client.list_stacks = mock.Mock(return_value=[])
|
||||
@ -549,7 +575,8 @@ class StackControllerTest(ControllerTest, HeatTestCase):
|
||||
rpc_client.count_stacks.assert_called_once_with(mock.ANY,
|
||||
filters=mock.ANY,
|
||||
tenant_safe=True,
|
||||
show_deleted=True)
|
||||
show_deleted=True,
|
||||
show_nested=False)
|
||||
|
||||
@mock.patch.object(rpc_client.EngineClient, 'call')
|
||||
def test_detail(self, mock_call, mock_enforce):
|
||||
|
Loading…
Reference in New Issue
Block a user