Raise TypeError in manilaclient/common/httpclient.py

object 'HTTPClient' property 'retries' is None for default,
when code 'if attempts > self.retries:' is executed at some time,
TypeError will raise.

Change-Id: I37c6235d30edc3afc5c5e2c88d710b6c60f49311
Closes-Bug: #1664877
This commit is contained in:
drngsl
2017-02-15 03:24:42 -05:00
parent 7f95f10286
commit 788001fcaf
2 changed files with 10 additions and 1 deletions

View File

@@ -48,7 +48,7 @@ class HTTPClient(object):
http_log_debug=False):
self.endpoint_url = endpoint_url
self.base_url = self._get_base_url(self.endpoint_url)
self.retries = retries
self.retries = int(retries or 0)
self.http_log_debug = http_log_debug
self.request_options = self._set_request_options(

View File

@@ -176,6 +176,15 @@ class ClientTest(utils.TestCase):
test_get_call()
self.assertEqual(self.requests, [])
def test_get_with_retries_none(self):
cl = get_authed_client(retries=None)
@mock.patch.object(requests, "request", bad_401_request)
def test_get_call():
resp, body = cl.get("/hi")
self.assertRaises(exceptions.Unauthorized, test_get_call)
def test_post(self):
cl = get_authed_client()