summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliushuai <liushuai@cmss.chinamobile.com>2018-11-26 23:53:36 +0800
committerliushuai <liushuai@cmss.chinamobile.com>2018-11-27 13:45:59 +0800
commit2be6e2a49613c850b8961a12bfc2f73377764dfd (patch)
tree3b79fc839dd219b0b2ac72556e1b49655b9a086d
parentd2655031ae78c621d89ec803e750b1f9814ec952 (diff)
Fix raise error in create plan process
Notes
Notes (review): Code-Review+2: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Workflow+1: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Tue, 27 Nov 2018 07:15:38 +0000 Reviewed-on: https://review.openstack.org/620096 Project: openstack/karbor Branch: refs/heads/master
-rw-r--r--karbor/api/v1/plans.py2
-rw-r--r--karbor/tests/unit/api/v1/test_plans.py10
2 files changed, 11 insertions, 1 deletions
diff --git a/karbor/api/v1/plans.py b/karbor/api/v1/plans.py
index 16014ef..bb2f59e 100644
--- a/karbor/api/v1/plans.py
+++ b/karbor/api/v1/plans.py
@@ -403,7 +403,7 @@ class PlansController(wsgi.Controller):
403 try: 403 try:
404 provider = self.protection_api.show_provider( 404 provider = self.protection_api.show_provider(
405 context, plan["provider_id"]) 405 context, plan["provider_id"])
406 except exception: 406 except Exception:
407 msg = _("The provider could not be found.") 407 msg = _("The provider could not be found.")
408 raise exc.HTTPBadRequest(explanation=msg) 408 raise exc.HTTPBadRequest(explanation=msg)
409 options_schema = provider.get( 409 options_schema = provider.get(
diff --git a/karbor/tests/unit/api/v1/test_plans.py b/karbor/tests/unit/api/v1/test_plans.py
index 576fe7c..0b5f527 100644
--- a/karbor/tests/unit/api/v1/test_plans.py
+++ b/karbor/tests/unit/api/v1/test_plans.py
@@ -97,6 +97,16 @@ class PlanApiTest(base.TestCase):
97 req, body=body) 97 req, body=body)
98 98
99 @mock.patch( 99 @mock.patch(
100 'karbor.services.protection.rpcapi.ProtectionAPI.show_provider')
101 def test_plan_create_InvalidProvider(self, mock_provider):
102 plan = self._plan_in_request_body()
103 body = {"plan": plan}
104 req = fakes.HTTPRequest.blank('/v1/plans')
105 mock_provider.side_effect = exception.NotFound()
106 self.assertRaises(exc.HTTPBadRequest, self.controller.create,
107 req, body=body)
108
109 @mock.patch(
100 'karbor.api.v1.plans.PlansController._plan_get') 110 'karbor.api.v1.plans.PlansController._plan_get')
101 @mock.patch( 111 @mock.patch(
102 'karbor.api.v1.plans.PlansController._plan_update') 112 'karbor.api.v1.plans.PlansController._plan_update')