コード例 #1
0
ファイル: kafka.py プロジェクト: disqus/pgshovel
def test_validates_stream_and_crashes_when_invalid(writer, stream, state):
    messages = list(islice(transactions(), 3))
    messages[1] = messages[0]

    writer.push(messages)

    with pytest.raises(SequencingError):
        list(stream.consume(state))
コード例 #2
0
ファイル: kafka.py プロジェクト: disqus/pgshovel
def test_uses_existing_stream_state_if_it_exists(writer, stream, state):
    writer.push(islice(transactions(), 6))

    iterator = stream.consume(state)

    next(iterator)
    next(iterator)
    (new_state, offset, message) = next(iterator)

    new_iterator = stream.consume(new_state)

    (_, new_offset, _) = next(new_iterator)
    assert new_offset == 3
コード例 #3
0
ファイル: kafka.py プロジェクト: disqus/pgshovel
def sliced_transaction():
    two_transactions = list(islice(transactions(), 6))

    head, remainder = two_transactions[0], two_transactions[1:]
    assert head.batch_operation.begin_operation == begin
    yield remainder