我正在尝试减少和清理GAE数据存储区中的数据存储区索引,所以我设置require_indexes = True。我删除了所有索引并运行了我的单元测试,但测试没有出现问题,并且GAE SDK没有对index.yaml进行任何更改。为什么要通过?????
答案 0 :(得分:0)
我认为解决方案是djangoappengine.sb.stubs.activate_test_stubs需要更新如下才能要求和设置索引:
def activate_test_stubs(self, connection):
if self.active_stubs == 'test':
return
os.environ['HTTP_HOST'] = "%s.appspot.com" % appid
appserver_opts = connection.settings_dict.get('DEV_APPSERVER_OPTIONS', {})
high_replication = appserver_opts.get('high_replication', False)
require_indexes = appserver_opts.get('require_indexes', False)
datastore_opts = {'require_indexes': require_indexes}
if high_replication:
from google.appengine.datastore import datastore_stub_util
datastore_opts['consistency_policy'] = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=1)
if self.testbed is None:
from google.appengine.ext.testbed import Testbed
self.testbed = Testbed()
self.testbed.activate()
self.pre_test_stubs = self.active_stubs
self.active_stubs = 'test'
self.testbed.init_datastore_v3_stub(root_path=PROJECT_DIR, **datastore_opts)
self.testbed.init_memcache_stub()
self.testbed.init_taskqueue_stub(auto_task_running=True, root_path=PROJECT_DIR)
self.testbed.init_urlfetch_stub()
self.testbed.init_user_stub()
self.testbed.init_xmpp_stub()
self.testbed.init_channel_stub()
if require_indexes:
from google.appengine.tools import dev_appserver_index
dev_appserver_index.SetupIndexes(None, None)
Alex Burgel已经通过这些更改在github上更新了djangoappengine。