On Thursday, January 16, 2020 at 1:47:03 PM UTC-8, Ryan B wrote: > > * replace testbed > <https://cloud.google.com/appengine/docs/standard/python/refdocs/google.appengine.ext.testbed> > > with the datastore emulator > <https://cloud.google.com/datastore/docs/tools/datastore-emulator> for > running unit tests without mocking out ndb. example commands. > <https://github.com/snarfed/granary#development> >
Ryan, I was wondering if you could elaborate a bit more on what you did here. I'm working on migrating an app with several hundred unit tests but there's a couple of items that I'm either a little stuck on or have me on edge: 1) First and foremost, I had repeated issues with dev_appserver connecting to my production datastore despite having set all the correct environment variables and setting the --support_datastore_emulator flag. I was finally able to solve it by explicitly passing *--env_var DATASTORE_EMULATOR_HOST=localhost:8081*, but I'm not immediately sure how to do that from within our unittest framework and I'm very worried about our unit tests writing to the production datastore. (For the time being, I used the gcloud CLI to change my project to a dummy one.) 2) This is maybe my own unfamiliarity with NDB context, but I'm not sure what the correct way is to use the same NDB context across all unit tests. I borrowed your WSGI middleware trick for the app itself, but I haven't yet quite figured out how to apply a single context across our entire unittest suite. I tried creating a new NDB context in our base setUp method, which looked like it was working but dragged the test speed to a crawl. Just curious if you had any additional insights or example code available. I've already learned quite a bit by reading through your other postings, so thanks regardless. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/d2699444-923d-4f2b-8243-56573392617a%40googlegroups.com.
