unit testing gae with login setting in app.yaml
I'm unit testing a google app engine app that uses the login setting in the app.yaml file. E.g.,
- url: /profile
script: main.py
login: required
I'm using testbed, nose, nose-gae, and webtest though not sure which of those matter.
My problem is that the login setting from app.yaml is ignored during testing. So if I don't have a l开发者_如何学Googged in user and call
response = self.app.get("/profile")
I get the requested page instead of being redirected to the login page.
Is there a way to test the login settings from app.yaml?
Not using a unit test. Your tests are calling the handler directly, which doesn't involve the dev_appserver
, which is the component that enforces these restrictions. If you want to test these restrictions, you'll need an end-to-end test that invokes the dev_appserver and calls it over HTTP.
I realize this is almost 2 years later, but I had a similar problem and came upon a solution that's been developed lately.
There is now a "regression test framework" for devappserver2, which is the default development appserver as of 1.7.6. It sets up a server that will indeed use the app.yaml security settings and does this kind of integration testing
精彩评论