diff options
author | Jenkins <jenkins@review.openstack.org> | 2012-07-03 16:59:24 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2012-07-03 16:59:24 +0000 |
commit | d64b4152dd435e9a21e3612a57bda796915e2332 (patch) | |
tree | 7466ef759f8fb23561fe50ba7d8c35dece43b2eb | |
parent | a1194d29de8959744ff57bc472a1ae6ef72cf3e1 (diff) | |
parent | f75310c623ebebec3e23335e6dab07fabbddd423 (diff) | |
download | python-keystoneclient-d64b4152dd435e9a21e3612a57bda796915e2332.tar.gz |
Merge "decoding json only on 2xx success response bug 1007661"
-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() |