I am building an application with Python 2.7 using the Google App Engine framework. To test my application I have a several tests that are run through nosetests making use of the nosegae plugin. I run them with the following command:
nosetests --with-gae --gae-lib-root=/usr/local/google_appengine/ -w . -w */test/ -v
In the model layer of my application, I have the need to run several database operations that affect multiple entity groups inside the same transaction. I do this by making use of the run_in_transaction_options function of the db package: https://developers.google.com/appengine/docs/python/datastore/functions#run_in_transaction
Unfortunately, when running my test suites, I get the following error in those testcases that try to run such transaction:
BadRequestError: transactions on multiple entity groups only allowed with the High Replication datastore
I cannot find any flag in nosetests that makes it possible to enable the HRD.
I am wondering if it is possible at all to run HRD from nosetests and if so, how it can be set up?
I would highly suggest you to switch from db to ndb, where you can use cross group transactions.
To simulate the HRD, you can add this part to the setUp
function of your tests, from Writing High Replication Datastore tests:
# Create a consistency policy that will simulate the High Replication consistency model.
self.policy = datastore_stub_util.PseudoRandomHRConsistencyPolicy(probability=0)
# Initialize the datastore stub with this policy.
self.testbed.init_datastore_v3_stub(consistency_policy=self.policy)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With