繁体   English   中英

Google应用引擎预期搜索的测试平台存根

[英]Testbed stub for Google app engine prospective search

对于Google App Engine“搜索” ,除了“预期搜索”服务外,我与Testbed存根基本存在相同的问题。

我正在尝试对使用准搜索的应用程序进行一些单元测试,并且得到:

AssertionError: No api proxy found for service "matcher"

我查看了受支持的存根文档问题跟踪程序的列表 ,但没有找到任何有用的参考。

一旦找到预期搜索的存根,在Google App Engine“搜索”的Testbed存根上可接受的答案已经指向正确的方向。

可以在google.appengine.api.prospective_search.prospective_search_stub找到此类存根

我选择在代码中修改SUPPORTED_SERVICES列表,以便将来对SDK的更新不会破坏这一点。 尽管我同意,任何解决方案无论如何都是hack。

因此,一切最终都像这样。

在测试模块中:

from google.appengine.ext import testbed
    #Workaround to avoid prospective search complain until there is a proper
    #testbed stub
from google.appengine.api.prospective_search.prospective_search_stub \
    import ProspectiveSearchStub
PROSPECTIVE_SEARCH_SERVICE_NAME = "matcher"
testbed.SUPPORTED_SERVICES.append(PROSPECTIVE_SEARCH_SERVICE_NAME)

并在def setUp(self):

ps_stub = ProspectiveSearchStub('./ps.txt', None)
self.testbed._register_stub(PROSPECTIVE_SEARCH_SERVICE_NAME, ps_stub)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM