开发者

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜