本文整理汇总了Python中appscale.datastore.datastore_distributed.DatastoreDistributed.put_entities方法的典型用法代码示例。如果您正苦于以下问题:Python DatastoreDistributed.put_entities方法的具体用法?Python DatastoreDistributed.put_entities怎么用?Python DatastoreDistributed.put_entities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appscale.datastore.datastore_distributed.DatastoreDistributed
的用法示例。
在下文中一共展示了DatastoreDistributed.put_entities方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_put_entities
# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import put_entities [as 别名]
def test_put_entities(self):
app_id = 'test'
db_batch = flexmock()
db_batch.should_receive('valid_data_version').and_return(True)
entity_proto1 = self.get_new_entity_proto(
app_id, "test_kind", "bob", "prop1name", "prop1val", ns="blah")
entity_key1 = 'test\x00blah\x00test_kind:bob\x01'
entity_proto2 = self.get_new_entity_proto(
app_id, "test_kind", "nancy", "prop1name", "prop2val", ns="blah")
entity_key2 = 'test\x00blah\x00test_kind:nancy\x01'
entity_list = [entity_proto1, entity_proto2]
db_batch.should_receive('batch_get_entity').and_return(
{entity_key1: {}, entity_key2: {}})
db_batch.should_receive('batch_mutate')
transaction_manager = flexmock(
create_transaction_id=lambda project, xg: 1,
delete_transaction_id=lambda project, txid: None)
dd = DatastoreDistributed(db_batch, transaction_manager,
self.get_zookeeper())
entity_lock = flexmock(EntityLock)
entity_lock.should_receive('acquire')
entity_lock.should_receive('release')
dd.put_entities(app_id, entity_list)
示例2: test_put_entities
# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import put_entities [as 别名]
def test_put_entities(self):
app_id = 'test'
db_batch = flexmock()
db_batch.should_receive('valid_data_version_sync').and_return(True)
entity_proto1 = self.get_new_entity_proto(
app_id, "test_kind", "bob", "prop1name", "prop1val", ns="blah")
entity_key1 = 'test\x00blah\x00test_kind:bob\x01'
entity_proto2 = self.get_new_entity_proto(
app_id, "test_kind", "nancy", "prop1name", "prop2val", ns="blah")
entity_key2 = 'test\x00blah\x00test_kind:nancy\x01'
entity_list = [entity_proto1, entity_proto2]
async_result = gen.Future()
async_result.set_result({entity_key1: {}, entity_key2: {}})
db_batch.should_receive('batch_get_entity').and_return(async_result)
db_batch.should_receive('normal_batch').and_return(ASYNC_NONE)
transaction_manager = flexmock(
create_transaction_id=lambda project, xg: 1,
delete_transaction_id=lambda project, txid: None,
set_groups=lambda project, txid, groups: None)
dd = DatastoreDistributed(db_batch, transaction_manager,
self.get_zookeeper())
dd.index_manager = flexmock(
projects={app_id: flexmock(indexes_pb=[])})
async_true = gen.Future()
async_true.set_result(True)
entity_lock = flexmock(EntityLock)
entity_lock.should_receive('acquire').and_return(async_true)
entity_lock.should_receive('release')
yield dd.put_entities(app_id, entity_list)
示例3: test_put_entities
# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import put_entities [as 别名]
def test_put_entities(self):
app_id = 'test'
db_batch = flexmock()
db_batch.should_receive('valid_data_version').and_return(True)
zookeeper = flexmock()
zookeeper.should_receive("acquire_lock").and_return(True)
entity_proto1 = self.get_new_entity_proto(
app_id, "test_kind", "bob", "prop1name", "prop1val", ns="blah")
entity_key1 = 'test\x00blah\x00test_kind:bob\x01'
entity_proto2 = self.get_new_entity_proto(
app_id, "test_kind", "nancy", "prop1name", "prop2val", ns="blah")
entity_key2 = 'test\x00blah\x00test_kind:nancy\x01'
entity_list = [entity_proto1, entity_proto2]
db_batch.should_receive('batch_get_entity').and_return(
{entity_key1: {}, entity_key2: {}})
db_batch.should_receive('batch_mutate')
dd = DatastoreDistributed(db_batch, zookeeper)
# Make sure it does not throw an exception
txn_hash = {entity_key1: 1, entity_key2: 1}
dd.put_entities(app_id, entity_list, txn_hash)