Is there a way to get local unit tests with google.appengine.ext.testbed to automatically generate indexes the same way the dev server does? I've tried the following which doesn't seem to work:
from google.appengine.tools import dev_appserver_index
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub(require_indexes=True)
dev_appserver_index.SetupIndexes(None, root_directory)
dev_appserver_index.IndexYamlUpdater(root_directory).UpdateIndexYaml()
I've tried adding the dev_appserver_index bits to both setUp() and tearDown(). I've tried initializing the datastore_v3_stub with require_indexes=True and require_indexes=False. Nothing seems to work.
You must call the init_datastore_v3_stub method with a root_path option as below:
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub(root_path="your-root-path")
The root_path is path of a directory that exists a app.yaml file.
It raises NeedIndexError, if you set the require_indexes option to True.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With