Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flushing python GAE datastore when unit testing

I am following the recommendations on the app engine site for unit testing coding with GAE. I have set the PseudoRandomHRConsistencyPolicy probability to 0% to force the code to account for cases where the data is not yet consistent. The problem is that in my test suite I want to do some data setup (creating and adding data to the datastore) and need a way to force the datastore to flush all the data into a consistent state before I exercise the code under test. (ie. make sure that the datastore will return all global entities I have written the next time I do a query).

Is there any way to do this and if not, how are other people setting up data in their tests suites when they are using the consistency models?

like image 975
Allen Avatar asked Sep 26 '11 20:09

Allen


1 Answers

The key to doing this is noted near the end of the section on HRD testing:

In the local environment, performing a get() of an Entity that belongs to an entity group with an unapplied write will always make the results of the unapplied write visible to subsequent global queries. In production this is not the case.

Simply add some get operations to your tests to get the appropriate records, and they will show up in future queries.

like image 185
Nick Johnson Avatar answered Nov 01 '22 09:11

Nick Johnson