Google App Engine要求索引进行测试 [英] Google App Engine Require Indexes for tests
问题描述
我的功能测试让我有些困惑,没有使用与dev_appserver相同的设置.目前,我使用require_indexes运行我的dev_appserver(非rel).
I just got bit by my functional tests not using the same settings as my dev_appserver. I currently run my dev_appserver (non-rel) with require_indexes.
如何强制我的测试床使用相同的设置?
How to I force my test bed to use the same setings?
我尝试使用 SetupIndexes
,但是它没有要求"在我的index.yaml中定义它们.我没有正确的设置,因此我可以执行任何查询.
I have tried using SetupIndexes
but it did not "require" they be defined in my index.yaml. I did not have the setting correct and as a result i can do any query I want.
即
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.
但是当查询在服务器上执行时,我得到了
but when the query executes on the server i get the
NeedIndexError:此查询需要一个未定义的复合索引.您必须在应用程序根目录中更新index.yaml文件.以下索引是所需的最低索引:
NeedIndexError: This query requires a composite index that is not defined. You must update the index.yaml file in your application root. The following index is the minimum index required:
推荐答案
尝试将{"require_indexes":True}添加为init_datastore_v3_stub()的关键字参数
Try adding { "require_indexes" : True } as a keyword argument to init_datastore_v3_stub()
您可以浏览(并逐步浏览)SDK代码,以查看该参数最终如何传递到数据存储区存根中.
You can look through (and step through) the SDK code to see how that parameter is eventually passed into the datastore stub.
这篇关于Google App Engine要求索引进行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!