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