コード例 #1
0
def test_append_timeout():
    acc = RecordAccumulator(RawBuffer, CONFIG)
    acc.try_append(b'-')
    time.sleep(0.2)
    assert acc.is_ready()

    acc.flush()
    assert not acc.is_ready()
コード例 #2
0
def test_append_over_kinesis_record_size():
    acc = RecordAccumulator(RawBuffer, CONFIG)
    success = acc.try_append(b'-' * (1024 * 1024))
    assert not success

    acc.flush()
    success = acc.try_append(b'-')
    assert success
コード例 #3
0
def test_append():
    acc = RecordAccumulator(RawBuffer, CONFIG)
    success = acc.try_append(b'-')
    assert success

    acc.flush()
    success = acc.try_append(b'-')
    assert success
コード例 #4
0
def test_has_record():
    acc = RecordAccumulator(RawBuffer, CONFIG)
    assert not acc.has_records()

    acc.try_append(b'-')
    assert acc.has_records()

    acc.flush()
    assert not acc.has_records()

    acc.try_append(b'-')
    assert acc.has_records()
コード例 #5
0
def test_flush_if_ready(config):
    q = queue.Queue()
    accumulator = RecordAccumulator(RawBuffer, config)
    client = mock.Mock()

    sender = Sender(queue=q, accumulator=accumulator,
                    client=client, partitioner=partitioner)

    accumulator.try_append(b'-' * 200)
    sender.run_once()

    assert client.put_record.called
    assert not accumulator.has_records()
コード例 #6
0
def test_flush(config):
    q = queue.Queue()
    accumulator = RecordAccumulator(RawBuffer, config)
    client = mock.Mock()

    sender = Sender(queue=q, accumulator=accumulator,
                    client=client, partitioner=partitioner)

    sender.flush()
    assert not client.put_record.called

    accumulator.try_append(b'-')

    sender.flush()
    expected_record = (b'-\n', 4)
    client.put_record.assert_called_once_with(expected_record)
コード例 #7
0
def test_flush():
    acc = RecordAccumulator(RawBuffer, CONFIG)
    acc.try_append(b'123')
    acc.try_append(b'456')
    acc.try_append(b'789')
    assert acc.flush() == b'123X456X789X'

    acc.try_append(b'ABC')
    assert acc.flush() == b'ABCX'
コード例 #8
0
def test_append_over_buffer_size():
    acc = RecordAccumulator(RawBuffer, CONFIG)
    success = acc.try_append(b'-' * 200)
    assert success
    assert acc.is_ready()