Fix exception message in Http.py
In common.http.py, the exception RequestTimeout has wrong message.This patch fixed it. Change-Id: Ie8ff188b9c82ce424cb8177278f36e4d1275b306
This commit is contained in:
parent
16ab18b64d
commit
b48ff98e16
glanceclient
@ -251,7 +251,7 @@ class HTTPClient(_BaseHTTPClient):
|
||||
headers=headers,
|
||||
**kwargs)
|
||||
except requests.exceptions.Timeout as e:
|
||||
message = ("Error communicating with %(endpoint)s: %(e)s" %
|
||||
message = ("Error communicating with %(url)s: %(e)s" %
|
||||
dict(url=conn_url, e=e))
|
||||
raise exc.InvalidEndpoint(message=message)
|
||||
except (requests.exceptions.ConnectionError, ProtocolError) as e:
|
||||
@ -321,7 +321,9 @@ class SessionClient(adapter.Adapter, _BaseHTTPClient):
|
||||
data=data,
|
||||
**kwargs)
|
||||
except ksc_exc.RequestTimeout as e:
|
||||
message = ("Error communicating with %(endpoint)s %(e)s" %
|
||||
conn_url = self.get_endpoint(auth=kwargs.get('auth'))
|
||||
conn_url = "%s/%s" % (conn_url.rstrip('/'), url.lstrip('/'))
|
||||
message = ("Error communicating with %(url)s %(e)s" %
|
||||
dict(url=conn_url, e=e))
|
||||
raise exc.InvalidEndpoint(message=message)
|
||||
except ksc_exc.ConnectionRefused as e:
|
||||
|
@ -139,6 +139,20 @@ class TestClient(testtools.TestCase):
|
||||
for k, v in six.iteritems(identity_headers):
|
||||
self.assertEqual(v, headers[k])
|
||||
|
||||
def test_connection_timeout(self):
|
||||
"""
|
||||
Should receive an InvalidEndpoint if connection timeout.
|
||||
"""
|
||||
def cb(request, context):
|
||||
raise requests.exceptions.Timeout
|
||||
|
||||
path = '/v1/images'
|
||||
self.mock.get(self.endpoint + path, text=cb)
|
||||
comm_err = self.assertRaises(glanceclient.exc.InvalidEndpoint,
|
||||
self.client.get,
|
||||
'/v1/images')
|
||||
self.assertIn(self.endpoint, comm_err.message)
|
||||
|
||||
def test_connection_refused(self):
|
||||
"""
|
||||
Should receive a CommunicationError if connection refused.
|
||||
|
Loading…
x
Reference in New Issue
Block a user