Merge "Fix delete API of profile/policy/receiver resources"
This commit is contained in:
commit
52d30c907e
@ -661,7 +661,7 @@ class Resource(object):
|
||||
# openstacksdk's need.
|
||||
http_exc = translate_exception(err,
|
||||
request.best_match_language())
|
||||
raise exception.HTTPExceptionDisguise(http_exc)
|
||||
raise http_exc
|
||||
if isinstance(err, exc.HTTPServerError):
|
||||
LOG.error(
|
||||
_LE("Returning %(code)s to user: %(explanation)s"),
|
||||
|
@ -114,3 +114,4 @@ class PolicyController(wsgi.Controller):
|
||||
@util.policy_enforce
|
||||
def delete(self, req, policy_id):
|
||||
self.rpc_client.policy_delete(req.context, policy_id, cast=False)
|
||||
raise exc.HTTPNoContent()
|
||||
|
@ -137,3 +137,4 @@ class ProfileController(wsgi.Controller):
|
||||
@util.policy_enforce
|
||||
def delete(self, req, profile_id):
|
||||
self.rpc_client.profile_delete(req.context, profile_id, cast=False)
|
||||
raise exc.HTTPNoContent()
|
||||
|
@ -130,3 +130,4 @@ class ReceiverController(wsgi.Controller):
|
||||
@util.policy_enforce
|
||||
def delete(self, req, receiver_id):
|
||||
self.rpc_client.receiver_delete(req.context, receiver_id, cast=False)
|
||||
raise exc.HTTPNoContent()
|
||||
|
@ -82,8 +82,7 @@ class API(wsgi.Router):
|
||||
sub_mapper.connect("profile_delete",
|
||||
"/profiles/{profile_id}",
|
||||
action="delete",
|
||||
conditions={'method': 'DELETE'},
|
||||
success=204)
|
||||
conditions={'method': 'DELETE'})
|
||||
|
||||
# Policy Types
|
||||
res = wsgi.Resource(policy_types.PolicyTypeController(conf))
|
||||
@ -122,8 +121,7 @@ class API(wsgi.Router):
|
||||
sub_mapper.connect("policy_delete",
|
||||
"/policies/{policy_id}",
|
||||
action="delete",
|
||||
conditions={'method': 'DELETE'},
|
||||
success=204)
|
||||
conditions={'method': 'DELETE'})
|
||||
|
||||
# Clusters
|
||||
res = wsgi.Resource(clusters.ClusterController(conf))
|
||||
@ -247,8 +245,7 @@ class API(wsgi.Router):
|
||||
sub_mapper.connect("receiver_delete",
|
||||
"/receivers/{receiver_id}",
|
||||
action="delete",
|
||||
conditions={'method': 'DELETE'},
|
||||
success=204)
|
||||
conditions={'method': 'DELETE'})
|
||||
|
||||
# Webhooks
|
||||
res = wsgi.Resource(webhooks.WebhookController(conf))
|
||||
|
@ -28,3 +28,4 @@ class TestPolicyDelete(base.BaseSenlinAPITest):
|
||||
res = self.client.delete_obj('policies', self.policy_id)
|
||||
self.assertEqual(204, res['status'])
|
||||
self.assertIsNone(res['body'])
|
||||
self.assertEqual('0', res['content-length'])
|
||||
|
@ -28,3 +28,4 @@ class TestProfileDelete(base.BaseSenlinAPITest):
|
||||
res = self.client.delete_obj('profiles', self.profile_id)
|
||||
self.assertEqual(204, res['status'])
|
||||
self.assertIsNone(res['body'])
|
||||
self.assertEqual('0', res['content-length'])
|
||||
|
@ -35,3 +35,4 @@ class TestReceiverDelete(base.BaseSenlinAPITest):
|
||||
res = self.client.delete_obj('receivers', self.receiver_id)
|
||||
self.assertEqual(204, res['status'])
|
||||
self.assertIsNone(res['body'])
|
||||
self.assertEqual('0', res['content-length'])
|
||||
|
@ -29,10 +29,15 @@ class ClusteringAPIClient(rest_client.RestClient):
|
||||
version = 'v1'
|
||||
|
||||
def _parsed_resp(self, resp, body):
|
||||
# Parse status code and location
|
||||
res = {
|
||||
'status': int(resp['status']),
|
||||
'location': resp.get('location', None),
|
||||
'status': int(resp.pop('status')),
|
||||
'location': resp.pop('location', None)
|
||||
}
|
||||
# Parse other keys included in resp
|
||||
res.update(resp)
|
||||
|
||||
# Parse body
|
||||
if body and str(body) != 'null':
|
||||
res['body'] = self._parse_resp(body)
|
||||
else:
|
||||
|
@ -481,7 +481,8 @@ class PolicyControllerTest(shared.ControllerTest, base.SenlinTestCase):
|
||||
mock_call = self.patchobject(rpc_client.EngineClient, 'call',
|
||||
return_value=None)
|
||||
|
||||
self.controller.delete(req, policy_id=pid)
|
||||
self.assertRaises(exc.HTTPNoContent,
|
||||
self.controller.delete, req, policy_id=pid)
|
||||
|
||||
mock_call.assert_called_with(
|
||||
req.context, ('policy_delete', {'identity': pid}))
|
||||
|
@ -537,7 +537,8 @@ class ProfileControllerTest(shared.ControllerTest, base.SenlinTestCase):
|
||||
mock_call = self.patchobject(rpc_client.EngineClient, 'call',
|
||||
return_value=None)
|
||||
|
||||
self.controller.delete(req, profile_id=pid)
|
||||
self.assertRaises(exc.HTTPNoContent,
|
||||
self.controller.delete, req, profile_id=pid)
|
||||
|
||||
mock_call.assert_called_with(
|
||||
req.context, ('profile_delete', {'identity': pid}))
|
||||
|
@ -495,7 +495,8 @@ class ReceiverControllerTest(shared.ControllerTest, base.SenlinTestCase):
|
||||
mock_call = self.patchobject(rpc_client.EngineClient, 'call',
|
||||
return_value=None)
|
||||
|
||||
self.controller.delete(req, receiver_id=wid)
|
||||
self.assertRaises(exc.HTTPNoContent,
|
||||
self.controller.delete, req, receiver_id=wid)
|
||||
|
||||
mock_call.assert_called_with(
|
||||
req.context,
|
||||
|
@ -106,8 +106,7 @@ class RoutesTest(base.SenlinTestCase):
|
||||
'delete',
|
||||
'ProfileController',
|
||||
{
|
||||
'profile_id': 'bbbb',
|
||||
'success': '204'
|
||||
'profile_id': 'bbbb'
|
||||
})
|
||||
|
||||
def test_policy_types_handling(self):
|
||||
@ -173,8 +172,7 @@ class RoutesTest(base.SenlinTestCase):
|
||||
'delete',
|
||||
'PolicyController',
|
||||
{
|
||||
'policy_id': 'bbbb',
|
||||
'success': '204',
|
||||
'policy_id': 'bbbb'
|
||||
})
|
||||
|
||||
def test_cluster_collection(self):
|
||||
@ -384,8 +382,7 @@ class RoutesTest(base.SenlinTestCase):
|
||||
'delete',
|
||||
'ReceiverController',
|
||||
{
|
||||
'receiver_id': 'bbbb',
|
||||
'success': '204',
|
||||
'receiver_id': 'bbbb'
|
||||
})
|
||||
|
||||
def test_webhook_collection(self):
|
||||
|
Loading…
Reference in New Issue
Block a user