summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-27 07:15:38 +0000
committerGerrit Code Review <review@openstack.org>2018-11-27 07:15:38 +0000
commit6d9cecd0d2b13c4239aebae6583d1869802fb03f (patch)
tree3c399318e82358ee2fbc10cacce527af3f2a1b60
parent6deaf213dc4a55072d7c2b12d74e65fa180ecdb3 (diff)
parent2be6e2a49613c850b8961a12bfc2f73377764dfd (diff)
Merge "Fix raise error in create plan process"
-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')