diff options
| author | Simon Pasquier <pasquier.simon@gmail.com> | 2013-04-02 17:04:16 +0200 |
|---|---|---|
| committer | Simon Pasquier <pasquier.simon@gmail.com> | 2013-04-02 17:54:22 +0200 |
| commit | 9354f84e59440e6a6eade085e964a7374c73509f (patch) | |
| tree | 62214ced4b0586f0556122275ba58395f337465a | |
| parent | 8eaba001434d85f4b9125524ebf55aa8288aa12e (diff) | |
| download | python-heatclient-0.2.2.tar.gz | |
"heat stack-create" doesn't return the error message from server0.2.2
Change-Id: Icef10df6547e5830abb17edf5ed8c622b3b021b5
Fixes: bug #1163335
| -rw-r--r-- | heatclient/common/http.py | 8 | ||||
| -rw-r--r-- | tests/test_common_http.py | 18 |
2 files changed, 20 insertions, 6 deletions
diff --git a/heatclient/common/http.py b/heatclient/common/http.py index 576e364..16d1bf6 100644 --- a/heatclient/common/http.py +++ b/heatclient/common/http.py @@ -160,7 +160,7 @@ class HTTPClient(object): self.log_http_response(resp, body_str) if 400 <= resp.status < 600: - raise exc.from_response(resp, body_iter) + raise exc.from_response(resp, body_str) elif resp.status in (301, 302, 305): # Redirected. Reissue the request to the new location. location = resp.getheader('location', None) @@ -175,7 +175,7 @@ class HTTPClient(object): raise exc.InvalidEndpoint(message=message) return self._http_request(location, method, **kwargs) elif resp.status == 300: - raise exc.from_response(resp, body_iter) + raise exc.from_response(resp, body_str) return resp, body_str @@ -187,10 +187,10 @@ class HTTPClient(object): if 'body' in kwargs: kwargs['body'] = json.dumps(kwargs['body']) - resp, body_iter = self._http_request(url, method, **kwargs) + resp, body_str = self._http_request(url, method, **kwargs) if 'application/json' in resp.getheader('content-type', None): - body = ''.join([chunk for chunk in body_iter]) + body = body_str try: body = json.loads(body) except ValueError: diff --git a/tests/test_common_http.py b/tests/test_common_http.py index e32ce0e..eb10590 100644 --- a/tests/test_common_http.py +++ b/tests/test_common_http.py @@ -183,7 +183,14 @@ class HttpClientTest(unittest.TestCase): # Replay, create client, assert self.m.ReplayAll() client = http.HTTPClient('http://example.com:8004') - self.assertRaises(exc.HTTPNotFound, client.json_request, 'GET', '') + try: + client.json_request('GET', '') + self.fail('No exception raised') + except exc.HTTPNotFound as e: + # Assert that the raised exception can be converted to string + self.assertNotEqual(e.message, None) + except: + raise self.m.VerifyAll() def test_http_300_json_request(self): @@ -200,7 +207,14 @@ class HttpClientTest(unittest.TestCase): # Replay, create client, assert self.m.ReplayAll() client = http.HTTPClient('http://example.com:8004') - self.assertRaises(exc.HTTPMultipleChoices, client.json_request, 'GET', '') + try: + client.json_request('GET', '') + self.fail('No exception raised') + except exc.HTTPMultipleChoices as e: + # Assert that the raised exception can be converted to string + self.assertNotEqual(e.message, None) + except: + raise self.m.VerifyAll() #def test_https_json_request(self): |
