Console for Google App Engine 'search'

I am trying to test new Google App Engine full-text search features in Python using a development application server.

Is there a plug for the search , which allows you to check it with the testbed local testing?

The following is an example of 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() 

The exception foo() by foo() is: AssertionError: No api proxy found for service "search" . Does api have a proxy for searching?

Thoughts and comments are appreciated.

+4
source share
2 answers

It seems that with SDK 1.8.4 you can disable the search loop 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() 
+5
source

UPDATE , it was really in 2012. In 2013, the situation changed: the stub was officially completed. See Answer @ siebz0r.

This is not a list of supported stubs (but I guess), but there SearchServiceStub in simple_search_stub.py, which looks like you.

I have not tested it myself, but you could try to do something like this:

 testbed = testbed.Testbed() testbed.activate() stub = SearchServiceStub() testbed._register_stub(SEARCH_SERVICE_NAME, stub) 

SEARCH_SERVICE_NAME must be "search" and it must also be in the SUPPORTED_SERVICES list, otherwise testbed will throw an exception .

The way you "enter" this new service stub either modifies the SDK / __ init__.py test bench or does it from your code. I can’t say which approach is better, since it will be hacked in any case, until init_search_stub () officially appears in the list.

In addition, the fact that he is not yet on the list is probably because he is simply not ready :) So, use it at your own risk.

+10
source

Source: https://habr.com/ru/post/1415834/


All Articles