I am doing image uploads as outlined in the documentation for the App Engine Images API, using getServingUrl() to generate an upload url, and then forwarding the request to my own handler. I am wondering if there is a good way of unit testing the image handling logic in my handler. If I instantiate my handler in a unit test and pass on a request to it, it fails with a “Must be called from a blob upload callback request”. Can I somehow mock it?
Share
Write a mock object that returns a known value from the getServingUrl method and then make sure that your class correctly reads that value and uses it to make the upload request. You have to assume that the GAE code is going to do the right thing in this case. The only logic you should concern yourself with is that which reads that url from GAE and subsequently posts to it with your blob data.