本文整理汇总了Python中appscale.datastore.datastore_distributed.DatastoreDistributed.delete_entities_txn方法的典型用法代码示例。如果您正苦于以下问题:Python DatastoreDistributed.delete_entities_txn方法的具体用法?Python DatastoreDistributed.delete_entities_txn怎么用?Python DatastoreDistributed.delete_entities_txn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appscale.datastore.datastore_distributed.DatastoreDistributed
的用法示例。
在下文中一共展示了DatastoreDistributed.delete_entities_txn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete_entities_txn
# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import delete_entities_txn [as 别名]
def test_delete_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)
keys = [entity.key()]
prefix = dd.get_table_prefix(entity.key())
entity_key = get_entity_key(prefix, entity.key().path())
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.DELETE,
dbconstants.TRANSACTIONS_SCHEMA[1]: entity_key,
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.delete_entities_txn(app, keys, txn_hash)