Search code examples
pythonunit-testinggoogle-app-enginenosetestbed

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 logged 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?


Solution

  • 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.