Merge "decoding json only on 2xx success response bug 1007661"

This commit is contained in:
Jenkins
2012-07-03 16:59:24 +00:00
committed by Gerrit Code Review

View File

@@ -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()