def test_put_entities_txn(self): app = 'guestbook' txn_hash = {'root_key': 1} txn_str = '1'.zfill(ID_KEY_LENGTH) entity = self.get_new_entity_proto(app, *self.BASIC_ENTITY[1:]) db_batch = flexmock() db_batch.should_receive('valid_data_version').and_return(True) dd = DatastoreDistributed(db_batch, None) entities = [entity] encoded_path = str(encode_index_pb(entity.key().path())) txn_keys = [dd._SEPARATOR.join([app, txn_str, '', encoded_path])] txn_values = { txn_keys[0]: { dbconstants.TRANSACTIONS_SCHEMA[0]: dbconstants.TxnActions.PUT, dbconstants.TRANSACTIONS_SCHEMA[1]: entity.Encode(), dbconstants.TRANSACTIONS_SCHEMA[2]: '' } } flexmock(dd).should_receive('get_root_key').and_return('root_key') db_batch.should_receive('batch_put_entity').with_args( dbconstants.TRANSACTIONS_TABLE, txn_keys, dbconstants.TRANSACTIONS_SCHEMA, txn_values, ttl=TX_TIMEOUT * 2 ) dd.put_entities_txn(entities, txn_hash, app)