当前位置: 首页>>代码示例>>Python>>正文


Python DatastoreDistributed.kindless_query方法代码示例

本文整理汇总了Python中appscale.datastore.datastore_distributed.DatastoreDistributed.kindless_query方法的典型用法代码示例。如果您正苦于以下问题:Python DatastoreDistributed.kindless_query方法的具体用法?Python DatastoreDistributed.kindless_query怎么用?Python DatastoreDistributed.kindless_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在appscale.datastore.datastore_distributed.DatastoreDistributed的用法示例。


在下文中一共展示了DatastoreDistributed.kindless_query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_kindless_query

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import kindless_query [as 别名]
  def test_kindless_query(self):
    query = datastore_pb.Query()
    ancestor = query.mutable_ancestor()
    entity_proto1 = self.get_new_entity_proto("test", "test_kind", "nancy", "prop1name", 
                                              "prop1val", ns="blah")
    entity_key = entity_proto1.key()
    get_req = datastore_pb.GetRequest()
    key = get_req.add_key() 
    key.MergeFrom(entity_key)
    
    tombstone1 = {'key': {APP_ENTITY_SCHEMA[0]:TOMBSTONE, APP_ENTITY_SCHEMA[1]: 1}}
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version').and_return(True)
    db_batch.should_receive("batch_get_entity").and_return(
               {"test\x00blah\x00test_kind:nancy\x01": 
                 {
                   APP_ENTITY_SCHEMA[0]: entity_proto1.Encode(),
                   APP_ENTITY_SCHEMA[1]: 1
                 }
               })

    db_batch.should_receive("batch_put_entity").and_return(None)
    entity_proto1 = {'test\x00blah\x00test_kind:nancy\x01':{APP_ENTITY_SCHEMA[0]:entity_proto1.Encode(),
                      APP_ENTITY_SCHEMA[1]: 1}}
    db_batch.should_receive("range_query").and_return([entity_proto1, tombstone1]).and_return([])
    zookeeper = flexmock()
    zookeeper.should_receive("get_valid_transaction_id").and_return(1)
    zookeeper.should_receive("is_in_transaction").and_return(False)
    zookeeper.should_receive("acquire_lock").and_return(True)
    dd = DatastoreDistributed(db_batch, zookeeper) 
    filter_info = {
      '__key__' : [[0, 0]]
    }
    dd.kindless_query(query, filter_info)
开发者ID:menivaitsi,项目名称:appscale,代码行数:36,代码来源:test_datastore_server.py

示例2: test_kindless_query

# 需要导入模块: from appscale.datastore.datastore_distributed import DatastoreDistributed [as 别名]
# 或者: from appscale.datastore.datastore_distributed.DatastoreDistributed import kindless_query [as 别名]
  def test_kindless_query(self):
    query = datastore_pb.Query()
    entity_proto1 = self.get_new_entity_proto(
      "test", "test_kind", "nancy", "prop1name", "prop1val", ns="blah")
    entity_key = entity_proto1.key()
    get_req = datastore_pb.GetRequest()
    key = get_req.add_key()
    key.MergeFrom(entity_key)

    async_result = gen.Future()
    async_result.set_result({
      "test\x00blah\x00test_kind:nancy\x01": {
        APP_ENTITY_SCHEMA[0]: entity_proto1.Encode(),
        APP_ENTITY_SCHEMA[1]: 1
      }
    })

    tombstone1 = {'key': {APP_ENTITY_SCHEMA[0]:TOMBSTONE, APP_ENTITY_SCHEMA[1]: 1}}
    db_batch = flexmock()
    db_batch.should_receive('valid_data_version_sync').and_return(True)
    db_batch.should_receive("batch_get_entity").and_return(async_result)

    entity_proto1 = {
      'test\x00blah\x00test_kind:nancy\x01': {
        APP_ENTITY_SCHEMA[0]:entity_proto1.Encode(),
        APP_ENTITY_SCHEMA[1]: 1
      }
    }
    async_result_1 = gen.Future()
    async_result_1.set_result([entity_proto1, tombstone1])
    async_result_2 = gen.Future()
    async_result_2.set_result([])
    db_batch.should_receive("range_query").\
      and_return(async_result_1).\
      and_return(async_result_2)

    zk_client = flexmock()
    zk_client.should_receive('add_listener')

    zookeeper = flexmock(handle=zk_client)
    zookeeper.should_receive("get_valid_transaction_id").and_return(1)
    zookeeper.should_receive("is_in_transaction").and_return(False)
    zookeeper.should_receive("acquire_lock").and_return(True)
    transaction_manager = flexmock()
    dd = DatastoreDistributed(db_batch, transaction_manager, zookeeper)
    filter_info = {
      '__key__' : [[0, 0]]
    }
    yield dd.kindless_query(query, filter_info)
开发者ID:AppScale,项目名称:appscale,代码行数:51,代码来源:test_datastore_server.py


注:本文中的appscale.datastore.datastore_distributed.DatastoreDistributed.kindless_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。