fix check parameters error

Closes-Bug #1822537

Change-Id: I2955a83b8c9e525b810aa5f17f9ee0f677d9bcec
This commit is contained in:
liushuai 2019-04-01 15:41:30 +08:00 committed by Jiao Pengju
parent 6598c51fba
commit b68009787a
2 changed files with 5 additions and 1 deletions

View File

@ -308,7 +308,7 @@ class PlansController(wsgi.Controller):
for key in valid_update_keys.intersection(plan):
update_dict[key] = plan[key]
if update_dict is None:
if not update_dict:
msg = _("Missing updated parameters in request body.")
raise exc.HTTPBadRequest(explanation=msg)

View File

@ -126,6 +126,10 @@ class PlanApiTest(base.TestCase):
self.assertRaises(
exception.ValidationError, self.controller.update,
req, "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", body=body)
body = {"plan": {}}
self.assertRaises(
exc.HTTPBadRequest, self.controller.update,
req, "2a9ce1f3-cc1a-4516-9435-0ebb13caa398", body=body)
def test_plan_update_InvalidId(self):
plan = self._plan_update_request_body()