404 status should raise 404 error, even if JSON is valid.
This commit is contained in:
parent
64d762d709
commit
921410d8f8
2 changed files with 3 additions and 7 deletions
|
@ -183,6 +183,9 @@ class OpenPhotoHttp:
|
|||
Decodes the JSON response, returning a dict.
|
||||
Raises an exception if an invalid response code is received.
|
||||
"""
|
||||
if response.status_code == 404:
|
||||
raise OpenPhoto404Error("HTTP Error %d: %s" %
|
||||
(response.status_code, response.reason))
|
||||
try:
|
||||
json_response = response.json()
|
||||
code = json_response["code"]
|
||||
|
@ -192,9 +195,6 @@ class OpenPhotoHttp:
|
|||
if 200 <= response.status_code < 300:
|
||||
# Status code was valid, so just reraise the exception
|
||||
raise
|
||||
elif response.status_code == 404:
|
||||
raise OpenPhoto404Error("HTTP Error %d: %s" %
|
||||
(response.status_code, response.reason))
|
||||
else:
|
||||
raise OpenPhotoError("HTTP Error %d: %s" %
|
||||
(response.status_code, response.reason))
|
||||
|
|
|
@ -61,8 +61,6 @@ class TestHttpErrors(unittest.TestCase):
|
|||
with self.assertRaises(openphoto.OpenPhotoError):
|
||||
self.client.post(self.test_endpoint)
|
||||
|
||||
# TODO: 404 status should raise 404 error, even if JSON is valid
|
||||
@unittest.expectedFailure
|
||||
@httpretty.activate
|
||||
def test_get_with_404_status(self):
|
||||
"""
|
||||
|
@ -73,8 +71,6 @@ class TestHttpErrors(unittest.TestCase):
|
|||
with self.assertRaises(openphoto.OpenPhoto404Error):
|
||||
self.client.get(self.test_endpoint)
|
||||
|
||||
# TODO: 404 status should raise 404 error, even if JSON is valid
|
||||
@unittest.expectedFailure
|
||||
@httpretty.activate
|
||||
def test_post_with_404_status(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue