0
我想減少和清理GAE數據存儲上我的數據存儲區索引,所以我設置require_indexes = True。我刪除了所有索引並運行了我的單元測試,但測試通過時沒有問題,並且GAE SDK沒有對index.yaml進行更改。爲什麼它會傳遞?????require_indexes在單元測試Djangoappengine
我想減少和清理GAE數據存儲上我的數據存儲區索引,所以我設置require_indexes = True。我刪除了所有索引並運行了我的單元測試,但測試通過時沒有問題,並且GAE SDK沒有對index.yaml進行更改。爲什麼它會傳遞?????require_indexes在單元測試Djangoappengine
我認爲解決的辦法是,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)
亞歷克斯Burgel對這些變化的github更新djangoappengine。