diff --git a/openphoto/openphoto_http.py b/openphoto/openphoto_http.py index 86a8b3d..d1e2475 100644 --- a/openphoto/openphoto_http.py +++ b/openphoto/openphoto_http.py @@ -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)) diff --git a/tests/unit/test_http_errors.py b/tests/unit/test_http_errors.py index d95a838..56b1d19 100644 --- a/tests/unit/test_http_errors.py +++ b/tests/unit/test_http_errors.py @@ -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): """