Google App Engine“搜索"的测试平台存根 [英] Testbed stub for Google App Engine 'search'

查看:59
本文介绍了Google App Engine“搜索"的测试平台存根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用开发应用服务器在Python中测试Google App Engine的新全文搜索功能.

I am trying to test Google App Engine's new full text search functionality in Python with the development appserver.

search ,从而可以使用 testbed a>本地单元测试?

Is there a stub for the search that allows one to test it with the testbed local unit testing?

以下是引发异常的示例代码:

The following is example code that throws an exception:

#!/usr/bin/python
from google.appengine.ext import testbed

from google.appengine.api import search

def foo():
    d = search.Document(doc_id='X',
        fields=[search.TextField(name='abc', value='123')])
    s = search.Index(name='one').add(d)

tb = testbed.Testbed()
tb.activate()
# tb.init_search_stub() ## does this exist?

foo()

foo()引发的异常为: AssertionError:未找到服务搜索"的api代理.是否已编写用于搜索的api代理?

The exception thrown by foo() is: AssertionError: No api proxy found for service "search". Has an api proxy been written for search?

感谢您的想法和评论.

推荐答案

似乎从SDK 1.8.4开始,可以从Testbed启用搜索存根:

It seems that since SDK 1.8.4 the search stub can be enabled from Testbed:

from google.appengine.api import search
from google.appengine.ext import testbed

try:
    tb = testbed.Testbed()
    tb.activate()
    tb.init_search_stub()
    index = search.Index(name='test')
    index.put(search.Document())
finally:
    tb.deactivate()

这篇关于Google App Engine“搜索"的测试平台存根的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆