Mismatch between response status and JSON code raises an exception
This commit is contained in:
parent
921410d8f8
commit
280521cf4a
2 changed files with 4 additions and 4 deletions
|
@ -199,6 +199,10 @@ class OpenPhotoHttp:
|
||||||
raise OpenPhotoError("HTTP Error %d: %s" %
|
raise OpenPhotoError("HTTP Error %d: %s" %
|
||||||
(response.status_code, response.reason))
|
(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:
|
if 200 <= code < 300:
|
||||||
return json_response
|
return json_response
|
||||||
elif (code == DUPLICATE_RESPONSE["code"] and
|
elif (code == DUPLICATE_RESPONSE["code"] and
|
||||||
|
|
|
@ -163,8 +163,6 @@ class TestHttpErrors(unittest.TestCase):
|
||||||
with self.assertRaises(openphoto.OpenPhotoDuplicateError):
|
with self.assertRaises(openphoto.OpenPhotoDuplicateError):
|
||||||
self.client.post(self.test_endpoint)
|
self.client.post(self.test_endpoint)
|
||||||
|
|
||||||
# TODO: Status code mismatch should raise an exception
|
|
||||||
@unittest.expectedFailure
|
|
||||||
@httpretty.activate
|
@httpretty.activate
|
||||||
def test_get_with_status_code_mismatch(self):
|
def test_get_with_status_code_mismatch(self):
|
||||||
"""
|
"""
|
||||||
|
@ -176,8 +174,6 @@ class TestHttpErrors(unittest.TestCase):
|
||||||
with self.assertRaises(openphoto.OpenPhotoError):
|
with self.assertRaises(openphoto.OpenPhotoError):
|
||||||
self.client.get(self.test_endpoint)
|
self.client.get(self.test_endpoint)
|
||||||
|
|
||||||
# TODO: Status code mismatch should raise an exception
|
|
||||||
@unittest.expectedFailure
|
|
||||||
@httpretty.activate
|
@httpretty.activate
|
||||||
def test_post_with_status_code_mismatch(self):
|
def test_post_with_status_code_mismatch(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue