Fix falcon.HTTPConflict initialization getting error

When creating a pool with duplicate database URI in V2 api,
Zaqar returns 500 internal error since falcon.HTTPConflict
initialization get error: "TypeError: __init__() takes
exactly 3 arguments (2 given)".

So there should use wsgi_errors.HTTPConflict(six.text_type(e))
to wrap falcon.HTTPConflict.

Closes-Bug: #1600537
Change-Id: I3c6cdef4cb175889a22400db0cf2ef81e27967f3
This commit is contained in:
wanghao 2016-07-10 09:57:15 +08:00
parent 2871900052
commit 9cfa5bc8ca
2 changed files with 8 additions and 1 deletions

View File

@ -139,6 +139,13 @@ class TestPoolsMongoDB(base.V2Base):
self.simulate_put(path, body=jsonutils.dumps(doc))
self.assertEqual(falcon.HTTP_400, self.srmock.status)
def test_put_same_database_uri(self):
# NOTE(cabrera): setUp creates default pool
expect = self.doc
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
self.simulate_put(path, body=jsonutils.dumps(expect))
self.assertEqual(falcon.HTTP_409, self.srmock.status)
def test_put_existing_overwrites(self):
# NOTE(cabrera): setUp creates default pool
expect = self.doc

View File

@ -192,7 +192,7 @@ class Resource(object):
raise falcon.HTTPBadRequest(title, six.text_type(e))
except errors.PoolAlreadyExists as e:
LOG.exception(e)
raise falcon.HTTPConflict(six.text_type(e))
raise wsgi_errors.HTTPConflict(six.text_type(e))
@acl.enforce("pools:delete")
def on_delete(self, request, response, project_id, pool):