Merge "Raise ConflictError like other transport errors"
This commit is contained in:
commit
6cff72fd23
@ -33,7 +33,6 @@ import json
|
||||
from oslo_utils import timeutils
|
||||
|
||||
from zaqarclient.queues.v1 import core
|
||||
from zaqarclient.transport import errors
|
||||
|
||||
queue_create = core.queue_create
|
||||
queue_exists = core.queue_exists
|
||||
@ -127,9 +126,6 @@ def subscription_create(transport, request, queue_name, subscription_data):
|
||||
request.content = json.dumps(subscription_data)
|
||||
resp = transport.send(request)
|
||||
|
||||
if resp.status_code == 409:
|
||||
raise errors.ConflictError()
|
||||
|
||||
return resp.deserialized_content
|
||||
|
||||
|
||||
|
@ -50,11 +50,15 @@ class QueuesV2SubscriptionUnitTest(base.QueuesTestBase):
|
||||
subscription_data = {'subscriber': 'http://trigger.me',
|
||||
'ttl': 3600}
|
||||
|
||||
with mock.patch.object(self.transport, 'send',
|
||||
autospec=True) as send_method:
|
||||
with mock.patch.object(self.transport.client, 'request',
|
||||
autospec=True) as request_method:
|
||||
|
||||
create_resp = response.Response(None, None, status_code=409)
|
||||
send_method.return_value = create_resp
|
||||
class FakeRawResponse(object):
|
||||
def __init__(self):
|
||||
self.text = ''
|
||||
self.headers = {}
|
||||
self.status_code = 409
|
||||
request_method.return_value = FakeRawResponse()
|
||||
|
||||
self.assertRaises(errors.ConflictError, self.client.subscription,
|
||||
'beijing', **subscription_data)
|
||||
|
@ -32,6 +32,7 @@ class HttpTransport(base.Transport):
|
||||
401: errors.UnauthorizedError,
|
||||
403: errors.ForbiddenError,
|
||||
404: errors.ResourceNotFound,
|
||||
409: errors.ConflictError,
|
||||
500: errors.InternalServerError,
|
||||
503: errors.ServiceUnavailableError
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user