Tom Willis
Tom Willis

Reputation: 5303

loading from app.yaml as a wsgi application

I couldn't immediately determine if this was possible by reading the source of the sdk.

But, is there a way to get a wsgi version of the application that dev_appserver would load from app.yaml?

I was so hoping there would be a function like

def app_from_yaml(path_to_yaml):
    ...

If this existed I could actually write automated tests for the blobstore logic and not have to do the crap manually anymore. Any Ideas?

Upvotes: 1

Views: 426

Answers (2)

schuppe
schuppe

Reputation: 2033

I'm not aware of any solution that does what you want. I strongly suspect the reason is that dev_appserver does a lot of things when loading an application, including parsing the various yaml files, set up routing, stub out APIs (both, App Engine and Python), restrict the environment to emulate appserver, and so on. A function app_from_yaml(path_to_yaml) would have to do what dev_appserver.py does. And since dev_appserver.py does it already, I think no-one bothered to add another implementation.

I see 2 ways to solve your problem.

  1. Make the blobstore API more testable
  2. start your app with dev_appserver and run tests against it

The former one is rather difficult because it would require to refactor how things are done currently which risks the introduction of subtle regressions. The latter is something we do a lot for such large tests (which are really integration tests). We use gaedriver for that.

In your specific case where you want to test blobstore (which we do, too), we start an app from within a test, upload a blob using a certain URL and then hit another and check if the blob was processed correctly. It's not as nice as using testbed, but it works, is fairly straight-forward and fairly fast.

Upvotes: 1

tdavis
tdavis

Reputation: 1472

I'm not 100% sure of what you're asking, but the answer may lie in google.appengine.ext.webapp.util.run_wsgi_app.

In terms of the blobstore itself, there is already google.appengine.api.blobstore.blobstore_stub which can be used to test against the Blobstore (though I don't really understand what "manually" means in your context, so maybe that's not helpful).

Upvotes: 1

Related Questions