1

To test my Google App Engine applications, I'm using nosegae, and gaetestbed. This seems to cover a lot of bases. I'd now like to create a test where users.get_current_user() returns a fake user of my choice. Ideally, I could change this from test to test independently.

The documentation at https://developers.google.com/appengine/docs/python/tools/localunittesting introduces google.appengine.ext.testbed which can do it. And the thread at Google App Engine set up a user when using testbed shows one way to do it.

The part I'm having trouble with is figuring out how to combine google.appengine.ext.testbed with nosegae and gaetestbed. It seems that nosegae and gaetestbed are already setting up the stubs and so on for me. And I know that gaetestbed is taking care of things like clearing the test datastore for me between tests. Do they setup a testbed object that I should find and call setup_env() on? Or should I create my own testbed object? Or would that conflict with nosegae and/or gaetestbed? Or maybe there's a way built into nosegae and gaetestbed which will help me do this type of thing? I've been searching documentation and the web to no avail so far.

Anyone know what the simplest/cleanest way to do this type of testing is?

Community
  • 1
  • 1
cds
  • 95
  • 6
  • Do not use gaetestbed. Use testbed. – new name Oct 27 '12 at 02:45
  • @kekito, could you elaborate on why? I started using gaetestbed because it handled clearing the datastore and it supplies a number of useful assertions and such. It'd be nice if I could keep those features if there's a way to make them work together. Does gaetestbed not use the appengine Testbed internally? Or does it do something incompatiable and that's the source of the problems? – cds Oct 27 '12 at 13:34
  • They are not meant to be used together. testbed is a replacement for gaetestbed. – new name Oct 27 '12 at 21:06

0 Answers0