python - Google App Engine 需要索引进行测试

标签 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: 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() 的关键字参数

您可以查看(并单步执行)SDK 代码以了解该参数最终是如何传递到数据存储 stub 中的。

关于python - Google App Engine 需要索引进行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11622683/

相关文章:

python - 如何在 python Webdriver 中鼠标悬停

unit-testing - 试图获得对 TDD 好处的信心

ruby - 获取/发布错误响应的 rspec 测试

安卓 : instumentation testing for app widgets

python - 使用 Python pandas Dataframe 进行嵌套连接

python - 如何用 Python 编写 24 位 WAV 文件?

python - Kivy UrlRequest不触发回调

java - Java JDK10 中的 TypeTags 错误

google-app-engine - 有什么方法可以实现 google appengine 多区域服务?

java - JSP::与 session 对象混淆