Skip to content

Commit

Permalink
decoding json only on 2xx success response
Browse files Browse the repository at this point in the history
bug 1007661

Change-Id: I9090c78bb9a19ae46d865fca80af0b3bf4257dc6
  • Loading branch information
heckj committed Jun 26, 2012
1 parent 44a1ee3 commit f75310c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import mock

from keystoneclient import client
from keystoneclient import exceptions
from tests import utils


Expand Down Expand Up @@ -41,6 +42,20 @@ def test_get_call():

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

Expand Down

0 comments on commit f75310c

Please sign in to comment.