本文整理汇总了Python中appscale.datastore.datastore_distributed.DatastoreDistributed.insert_composite_indexes方法的典型用法代码示例。如果您正苦于以下问题:Python DatastoreDistributed.insert_composite_indexes方法的具体用法?Python DatastoreDistributed.insert_composite_indexes怎么用?Python DatastoreDistributed.insert_composite_indexes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appscale.datastore.datastore_distributed.DatastoreDistributed
的用法示例。
在下文中一共展示了DatastoreDistributed.insert_composite_indexes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_insert_composite_indexes
# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import insert_composite_indexes [as 别名]
def test_insert_composite_indexes(self):
composite_index = entity_pb.CompositeIndex()
composite_index.set_id(123)
composite_index.set_app_id("appid")
definition = composite_index.mutable_definition()
definition.set_entity_type("kind")
prop1 = definition.add_property()
prop1.set_name("prop1")
prop1.set_direction(1) # ascending
prop2 = definition.add_property()
prop2.set_name("prop2")
prop1.set_direction(1) # ascending
ent = self.get_new_entity_proto(
"appid", "kind", "entity_name", "prop1", "value", ns="")
db_batch = flexmock()
db_batch.should_receive('valid_data_version_sync').and_return(True)
db_batch.should_receive("batch_put_entity").and_return(ASYNC_NONE).once()
transaction_manager = flexmock()
dd = DatastoreDistributed(db_batch, transaction_manager,
self.get_zookeeper())
yield dd.insert_composite_indexes([ent], [composite_index])