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()
def test_accumulate(config): q = queue.Queue() accumulator = RecordAccumulator(RawBuffer, config) client = mock.Mock() sender = Sender(queue=q, accumulator=accumulator, client=client, partitioner=partitioner) sender.run_once() assert not accumulator.has_records() q.put(b'-') sender.run_once() assert accumulator.has_records()
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()