Google App Engine requires indexes for tests

I just got my functional tests without using the same settings as my dev_appserver. I am currently running my dev_appserver (non-rel) with require_indexes.

How to make my test bed use the same settings?

I tried using SetupIndexes , but it didn’t “require” their definition in my index.yaml. I did not have the correct settings, and as a result, I can fulfill any request that I want.

i.e.

 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 request is executed on the server, I get

NeedIndexError: This query requires a composite index that is not defined. You must update the index.yaml file in the root of the application. The following index is the minimum required index:

0
source share
1 answer

Try adding {"require_indexes": True} as a keyword argument to init_datastore_v3_stub ()

You can view (and go over) the SDK code to see how this parameter is ultimately passed to the data store stub.

+2
source

Source: https://habr.com/ru/post/1013443/


All Articles