Exemplo n.º 1
0
def test_enqueue(spq_client, queue_name):
    request = spq_pb2.EnqueueRequest(
        item=bytes("item", "utf-8"),
        features=[{
            "name": "feature_name",
            "value": 0
        }],
        queueName=queue_name,
    )
    result = spq_client.Enqueue(request)

    assert result.size == 1
Exemplo n.º 2
0
def test_get_epoch(spq_client, queue_name):
    sent_item = bytes("item", "utf-8")

    request = spq_pb2.EnqueueRequest(
        item=sent_item,
        features=[{"name": "feature_name", "value": 0}],
        queueName=queue_name,
    )

    spq_client.Enqueue(request)

    result = spq_client.GetEpoch(spq_pb2.GetEpochRequest(queueName=queue_name))

    assert result.epoch > 0, result.epoch
Exemplo n.º 3
0
def test_get_size(spq_client, queue_name):
    request = spq_pb2.EnqueueRequest(
        item=bytes("item", "utf-8"),
        features=[{
            "name": "feature_name",
            "value": 0
        }],
        queueName=queue_name,
    )
    add_item_result = spq_client.Enqueue(request)

    get_size_result = spq_client.GetSize(
        spq_pb2.GetSizeRequest(queueName=queue_name))

    assert add_item_result.size == get_size_result.size
Exemplo n.º 4
0
def test_peek_item_does_not_alter_queue(spq_client, queue_name):
    request = spq_pb2.EnqueueRequest(
        item=bytes("item", "utf-8"),
        features=[{
            "name": "feature_name",
            "value": 0
        }],
        queueName=queue_name,
    )
    spq_client.Enqueue(request)

    peek_item_result = spq_client.Peek(
        spq_pb2.PeekRequest(queueName=queue_name))
    second_peek_item_result = spq_client.Peek(
        spq_pb2.PeekRequest(queueName=queue_name))

    assert peek_item_result == second_peek_item_result
Exemplo n.º 5
0
def test_dequeue(spq_client, queue_name):
    sent_item = bytes("item", "utf-8")

    request = spq_pb2.EnqueueRequest(
        queueName=queue_name,
        item=sent_item,
        features=[{
            "name": "feature_name",
            "value": 0
        }],
    )

    add_item_result = spq_client.Enqueue(request)

    result = spq_client.Dequeue(spq_pb2.DequeueRequest(queueName=queue_name))

    assert result.hasItem == True
    assert result.item == sent_item
    assert result.size == add_item_result.size - 1
Exemplo n.º 6
0
def test_peek_item(spq_client, queue_name):
    drain_queue(spq_client, queue_name)

    sent_item = bytes("peek_item", "utf-8")
    request = spq_pb2.EnqueueRequest(
        item=sent_item,
        features=[{
            "name": "feature_name",
            "value": 0
        }],
        queueName=queue_name,
    )
    add_item_result = spq_client.Enqueue(request)

    peek_item_result = spq_client.Peek(
        spq_pb2.PeekRequest(queueName=queue_name))

    assert peek_item_result.hasItem == True
    assert peek_item_result.item == sent_item
    assert peek_item_result.size == add_item_result.size