def test_with_error_status_and_invalid_json(self, method):
     """
     Check that invalid JSON causes the get/post methods to raise
     an exception, even with an error status is returned
     """
     self._register_uri(method, body="Invalid JSON", status=500)
     with self.assertRaises(trovebox.TroveboxError):
         GetOrPost(self.client, method).call(self.test_endpoint)
 def test_with_invalid_json(self, method):
     """
     Check that invalid JSON causes the get/post methods to
     raise an exception
     """
     self._register_uri(method, body="Invalid JSON")
     with self.assertRaises(ValueError):
         GetOrPost(self.client, method).call(self.test_endpoint)
 def test_404_status(self, method):
     """
     Check that a 404 status causes the get/post methods
     to raise a 404 exception
     """
     self._register_uri(method, status=404)
     with self.assertRaises(trovebox.Trovebox404Error):
         GetOrPost(self.client, method).call(self.test_endpoint)
 def test_with_status_code_mismatch(self, method):
     """
     Check that a mismatched HTTP status code still returns the
     JSON status code.
     """
     data = {"message": "Test Message", "code": 202}
     self._register_uri(method, data=data, status=200)
     response = GetOrPost(self.client, method).call(self.test_endpoint)
     self.assertEqual(response["code"], 202)
 def test_with_duplicate_status(self, method):
     """
     Check that a get/post with a duplicate status
     raises a duplicate exception
     """
     data = {"message": "This photo already exists", "code": 409}
     self._register_uri(method, data=data, status=409)
     with self.assertRaises(trovebox.TroveboxDuplicateError):
         GetOrPost(self.client, method).call(self.test_endpoint)
 def test_http_error_with_no_response_processing(self, method):
     """
     Check that get/post methods work with response processing disabled
     when an HTTP error code is returned.
     """
     httpretty.register_uri(method, self.test_uri, status=500)
     with self.assertRaises(trovebox.TroveboxError):
         response = GetOrPost(self.client,
                              method).call(self.test_endpoint,
                                           process_response=False)