decoding json only on 2xx success response
bug 1007661 Change-Id: I9090c78bb9a19ae46d865fca80af0b3bf4257dc6
This commit is contained in:
@@ -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()
|
||||
|
||||
|
Reference in New Issue
Block a user