Example #1
0
 def test_eventually_consistent_with_transaction():
     with pytest.raises(ValueError):
         _api.get_read_options(
             _options.ReadOptions(
                 read_consistency=_api.EVENTUAL, transaction=b"txfoo"
             )
         )
Example #2
0
def _datastore_run_query(query):
    """Run a query in Datastore.

    Args:
        query (query.QueryOptions): The query spec.

    Returns:
        tasklets.Future:
    """
    query_pb = _query_to_protobuf(query)
    partition_id = entity_pb2.PartitionId(project_id=query.project,
                                          namespace_id=query.namespace)
    read_options = _datastore_api.get_read_options(
        query, default_read_consistency=_datastore_api.EVENTUAL)
    request = datastore_pb2.RunQueryRequest(
        project_id=query.project,
        partition_id=partition_id,
        query=query_pb,
        read_options=read_options,
    )
    response = yield _datastore_api.make_call("RunQuery",
                                              request,
                                              timeout=query.timeout)
    log.debug(response)
    return response
Example #3
0
 def test_eventually_consistent():
     options = _api.get_read_options(
         _options.ReadOptions(read_consistency=_api.EVENTUAL)
     )
     assert options == datastore_pb2.ReadOptions(
         read_consistency=datastore_pb2.ReadOptions.EVENTUAL
     )
Example #4
0
def _datastore_run_query(query):
    """Run a query in Datastore.

    Args:
        query (query.QueryOptions): The query spec.

    Returns:
        tasklets.Future:
    """
    query_pb = _query_to_protobuf(query)
    partition_id = entity_pb2.PartitionId(project_id=query.project,
                                          namespace_id=query.namespace)
    read_options = _datastore_api.get_read_options(query)
    request = datastore_pb2.RunQueryRequest(
        project_id=query.project,
        partition_id=partition_id,
        query=query_pb,
        read_options=read_options,
    )
    response = yield _datastore_api.make_call("RunQuery",
                                              request,
                                              timeout=query.timeout)
    utils.logging_debug(log, response)
    raise tasklets.Return(response)
Example #5
0
 def test_args_override_transaction(context):
     with context.new(transaction=b"txfoo").use():
         options = _api.get_read_options(
             _options.ReadOptions(transaction=b"txbar")
         )
         assert options == datastore_pb2.ReadOptions(transaction=b"txbar")
Example #6
0
 def test_no_args_no_transaction():
     assert (
         _api.get_read_options(_options.ReadOptions())
         == datastore_pb2.ReadOptions()
     )