Unify the format of list response

Change the format of container_actions response for consistency
with other APIs. Right now, all the list response is of the
following format:

  {"xxx" [{...}, ...]}

Change-Id: I388548a1c15e61b62e802da634c7be8697ff05b9
This commit is contained in:
Hongbin Lu 2018-03-07 03:54:11 +00:00
parent 744a17376e
commit d99faddc5a
3 changed files with 26 additions and 24 deletions

View File

@ -1,4 +1,5 @@
[
{
"containerActions": [
{
"action": "create",
"container_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
@ -18,4 +19,4 @@
"user_id": "22e81669093742b7a74b1d715a9a5813"
}
]
}

View File

@ -115,7 +115,7 @@ class ContainersActionsController(base.Controller):
context, container.uuid)
actions = [self._format_action(action) for action in actions_raw]
return actions
return {"containerActions": actions}
@pecan.expose('json')
@exception.wrap_pecan_controller_exception

View File

@ -1910,8 +1910,9 @@ class TestContainerActionController(api_base.FunctionalTest):
test_container['uuid'])
self.assertEqual(200, response.status_int)
self.assertEqual(self._format_action(test_action),
self._format_action(response.json[0]))
self.assertEqual(
self._format_action(test_action),
self._format_action(response.json['containerActions'][0]))
@mock.patch('zun.objects.Container.get_by_uuid')
@mock.patch('zun.common.policy.enforce')