Merge "Raise ConflictError like other transport errors"

This commit is contained in:
Jenkins 2016-02-28 12:56:32 +00:00 committed by Gerrit Code Review
commit 6cff72fd23
3 changed files with 9 additions and 8 deletions

View File

@ -33,7 +33,6 @@ import json
from oslo_utils import timeutils from oslo_utils import timeutils
from zaqarclient.queues.v1 import core from zaqarclient.queues.v1 import core
from zaqarclient.transport import errors
queue_create = core.queue_create queue_create = core.queue_create
queue_exists = core.queue_exists queue_exists = core.queue_exists
@ -127,9 +126,6 @@ def subscription_create(transport, request, queue_name, subscription_data):
request.content = json.dumps(subscription_data) request.content = json.dumps(subscription_data)
resp = transport.send(request) resp = transport.send(request)
if resp.status_code == 409:
raise errors.ConflictError()
return resp.deserialized_content return resp.deserialized_content

View File

@ -50,11 +50,15 @@ class QueuesV2SubscriptionUnitTest(base.QueuesTestBase):
subscription_data = {'subscriber': 'http://trigger.me', subscription_data = {'subscriber': 'http://trigger.me',
'ttl': 3600} 'ttl': 3600}
with mock.patch.object(self.transport, 'send', with mock.patch.object(self.transport.client, 'request',
autospec=True) as send_method: autospec=True) as request_method:
create_resp = response.Response(None, None, status_code=409) class FakeRawResponse(object):
send_method.return_value = create_resp def __init__(self):
self.text = ''
self.headers = {}
self.status_code = 409
request_method.return_value = FakeRawResponse()
self.assertRaises(errors.ConflictError, self.client.subscription, self.assertRaises(errors.ConflictError, self.client.subscription,
'beijing', **subscription_data) 'beijing', **subscription_data)

View File

@ -32,6 +32,7 @@ class HttpTransport(base.Transport):
401: errors.UnauthorizedError, 401: errors.UnauthorizedError,
403: errors.ForbiddenError, 403: errors.ForbiddenError,
404: errors.ResourceNotFound, 404: errors.ResourceNotFound,
409: errors.ConflictError,
500: errors.InternalServerError, 500: errors.InternalServerError,
503: errors.ServiceUnavailableError 503: errors.ServiceUnavailableError
} }