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