Testbed stubs for Cloud Datastore?

509 views
Skip to first unread message

Blaine Garrett

unread,
Jan 7, 2019, 3:04:21 PM1/7/19
to google-appengine
I'm starting down the path of migrating python 2.7 Standard env projects to utilize the python 3.7 Standard beta runtime. As a 2nd generation runtime, I'm aware it is in beta and that it is very different from the 1st generation environments.

I have the python datastore client working as well as the data store emulator. This works quite well, but it fairly slow for integration tests. One nice feature of the 2.7 sdk was the testbed that provided stubs for the datastore, etc. While mocking the datastore client is a lot easier than mocking the old ndb module, it would be ideal to have something like the test bed stubs again.

Is there currently an equivalent of the testbed from Google? If not, is anyone aware of a 3rd party effort? 

Additionally, is anyone aware of an equivalent datastore interface to ndb? While, hard to mock, it was a very nice interface into datastore, not to mention the built in cache support.

Cheers,
~ Blaine

Cristian (Google Cloud Platform Support)

unread,
Jan 17, 2019, 10:32:46 AM1/17/19
to Google App Engine


Hello


Currently Google is advising customers to use tools specific to Python rather that being dependent on dep_appserver. To test Datastore in your local environment, you can use the Datastore emulator as described here and here. Unfortunately Google App Engine Python 3.7 Runtime does not provide the stub service. I have created a feature request for you. Please notice that there is no ETA for this type of requests nor a guarantee that it will be implemented.


Regarding your second question, I am not sure if the Datastore interface to ndb is supported by Google or if you are referring to a third party library. I have checked the current built-in third party libraries and I could not find an actual reference to it. For this, we would need more information and a link to the actual resources you are referring to.


Blaine Garrett

unread,
Jan 18, 2019, 2:57:10 PM1/18/19
to Google App Engine
Excellent. Thank you for the reply and making a ticket.

Since my original post, I did discover there is an overhead to instantiating the datastore client and ended up taking a singleton approach which considerably sped up the emulator and reduces the need for testbed to an extent,
Also, in another thread someone pointed out a 3rd-party port of the ndb library which seems promising - https://github.com/Bogdanp/anom-py

I did decide if I have to port things over to python 3.7, I might as well try out Node on the Standard environment. So far so good but I'm sure I'll continue to be python for a while still on existing projects.

To provide clarification to your last point, ndb was a ORM model wrapper to datastore interaction that was provided as part of the 1st generation python runtime. It was not 3rd party in that you could import it from the google package (from google.appengine.ext import ndb) but it is a python specific client rather than core infrastructure. 

Thanks again,
~ Blaine


Reply all
Reply to author
Forward
0 new messages