diff options
| author | Joe Heck <heckj@mac.com> | 2012-06-01 17:03:35 -0700 |
|---|---|---|
| committer | Joe Heck <heckj@mac.com> | 2012-06-26 09:24:38 -0700 |
| commit | f75310c623ebebec3e23335e6dab07fabbddd423 (patch) | |
| tree | 9b166a077c8109a1586597b5ca59d05cb76915a8 /tests/test_http.py | |
| parent | 44a1ee32e29825257cac5c0a61fc3be51b79eb65 (diff) | |
| download | python-keystoneclient-f75310c623ebebec3e23335e6dab07fabbddd423.tar.gz | |
decoding json only on 2xx success response
bug 1007661
Change-Id: I9090c78bb9a19ae46d865fca80af0b3bf4257dc6
Diffstat (limited to 'tests/test_http.py')
| -rw-r--r-- | tests/test_http.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_http.py b/tests/test_http.py index a2ed459..a015793 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -2,6 +2,7 @@ import httplib2 import mock from keystoneclient import client +from keystoneclient import exceptions from tests import utils @@ -41,6 +42,20 @@ class ClientTest(utils.TestCase): test_get_call() + def test_get_error(self): + cl = get_authed_client() + + fake_err_response = httplib2.Response({"status": 400}) + fake_err_body = 'Some evil plaintext string' + err_mock_request = mock.Mock(return_value=(fake_err_response, + fake_err_body)) + + @mock.patch.object(httplib2.Http, "request", err_mock_request) + def test_get_call(): + self.assertRaises(exceptions.BadRequest, cl.get, '/hi') + + test_get_call() + def test_post(self): cl = get_authed_client() |
