Mismatch between response status and JSON code raises an exception

This commit is contained in:
sneakypete81 2013-06-30 17:21:20 +01:00
parent 921410d8f8
commit 280521cf4a
2 changed files with 4 additions and 4 deletions

View file

@ -199,6 +199,10 @@ class OpenPhotoHttp:
raise OpenPhotoError("HTTP Error %d: %s" %
(response.status_code, response.reason))
if code != response.status_code:
raise OpenPhotoError(("Response status code %d does not match " +
"JSON status code %d") % (response.status_code,
code))
if 200 <= code < 300:
return json_response
elif (code == DUPLICATE_RESPONSE["code"] and

View file

@ -163,8 +163,6 @@ class TestHttpErrors(unittest.TestCase):
with self.assertRaises(openphoto.OpenPhotoDuplicateError):
self.client.post(self.test_endpoint)
# TODO: Status code mismatch should raise an exception
@unittest.expectedFailure
@httpretty.activate
def test_get_with_status_code_mismatch(self):
"""
@ -176,8 +174,6 @@ class TestHttpErrors(unittest.TestCase):
with self.assertRaises(openphoto.OpenPhotoError):
self.client.get(self.test_endpoint)
# TODO: Status code mismatch should raise an exception
@unittest.expectedFailure
@httpretty.activate
def test_post_with_status_code_mismatch(self):
"""