0

I'm trying to reduce and clean up my datastore indexes on GAE datastore, so I set require_indexes=True. I removed all indexes and ran my unit tests, but the tests pass without an issue and there is no changes made by the GAE SDK to index.yaml. Why is it passing?????

4

1 に答える 1

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 をこれらの変更で更新しました。

于 2014-04-07T13:01:34.123 に答える