Google App Engine需要测试索引

时间:2012-07-24 00:55:27

标签: python google-app-engine testing

我的功能测试没有使用与dev_appserver相同的设置。我目前使用require_indexes运行我的dev_appserver(非rel)。

如何强迫我的试验台使用相同的装置?

我尝试过使用SetupIndexes,但它没有“要求”它们在我的index.yaml中定义。我没有设置正确,因此我可以做任何我想要的查询。

clz.testbed = Testbed()
clz.testbed.activate()
clz.testbed.init_memcache_stub()
clz.testbed.init_taskqueue_stub()
clz.testbed.init_urlfetch_stub()
clz.testbed.init_datastore_v3_stub(use_sqlite=True, datastore_file=somepath)
SetupIndexes('','')

model.objects().filter(x=1, y=2.....) #will work regardless of index defined.

但是当在服务器上执行查询时,我得到了

  

NeedIndexError:此查询需要未定义的复合索引。您必须更新应用程序根目录中的index.yaml文件。   以下索引是所需的最小索引:

1 个答案:

答案 0 :(得分:3)

尝试添加{“require_indexes”:True}作为init_datastore_v3_stub()的关键字参数

您可以查看(并逐步执行)SDK代码,以了解该参数最终如何传递到数据存储区存根。