Question

I run my google app engine application in one of two ways...

  1. Directly by using the application from http://localhost:8080
  2. Or execute unit tests from http://localhost:8080/test

When I create entities by using the application directly, the data is visible in the Development Console (dataStore view).

However, when I execute the unit tests... even if they succeed and I can put() and get() data, the data does not show in the dataStore view. Any idea why I can't see my data? Even though it is there?

Notes:

  • I use GAEUnit for unit tests.
  • the data stored mostly consists of StringProperties().
  • I use Python and run Django on top of the GAE, don't know if that matters.
Was it helpful?

Solution

GAEUnit creates its own proxy stub datastore, using this code on line 357 of the current '2.0a for django' release:

temp_stub = datastore_file_stub.DatastoreFileStub(
    'GAEUnitDataStore', None, None, trusted=True)

This proxy datastore is only held in memory, so is deleted once the tests finish running. It is also empty when the tests start running, ie it does not contain any data currently in the default development datastore.

You can temporarily modify this to make it write to a file on your development system, eg:

temp_stub = datastore_file_stub.DatastoreFileStub(
    'GAEUnitDataStore', '/path/to/gaeunit.datastore', None, trusted=True)

Then run dev_appserver.py on a different port, eg:

dev_appserver.py --port=8081 --datastore_path=/path/to/gaeunit.datastore /path/to/application/

And then finally, open http://localhost:8081/_ah/admin in a browser to view the contents of the temporary datastore.

OTHER TIPS

Is there a chance your Dev Console DataStore view is looking at a different datastore than your django app is writing to? I had a similar issue with my Django/GAE setup and resolved it by explicitly saying the location of my datastore when starting up the dev server. To start the dev server this way, just go into the directory of your django project and type:

dev_appserver.py --datastore_path=/path/to/datastore/my_datastore --history_path=/path/to/datastore/my_datastore
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top