Fix improper prompt when update RC with existed one's name.

When update resource class with existed one's name,
the exception message was formatted by the updated resource
class's name, rather than the required existed one's name.
This patch formats the message with existed one's name, and
changing tests to add the right name.

Change-Id: I78ae8d872748de243d74b9954ce634fccf5e7310
Closes-Bug: #1663163
This commit is contained in:
ericxiett 2017-02-09 16:55:11 +08:00
parent 7b5c3ac11d
commit ff1133c8ba
2 changed files with 2 additions and 1 deletions

View File

@ -183,7 +183,7 @@ def update_resource_class(req):
except exception.ResourceClassExists:
raise webob.exc.HTTPConflict(
_('Resource class already exists: %(name)s') %
{'name': name},
{'name': rc.name},
json_formatter=util.json_error_formatter)
except exception.ResourceClassCannotUpdateStandard:
raise webob.exc.HTTPBadRequest(

View File

@ -151,6 +151,7 @@ tests:
status: 409
response_strings:
- Resource class already exists
- $ENVIRON['CUSTOM_RES_CLASS']
- name: update custom resource class
PUT: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS']