def test_partition_records_compacted_offset(mocker):
    """Test that messagesets are handle correctly
    when the fetch offset points to a message that has been compacted
    """
    batch_start = 0
    batch_end = 100
    fetch_offset = 42
    tp = TopicPartition('foo', 0)
    builder = MemoryRecordsBuilder(
        magic=2, compression_type=0, batch_size=9999999)

    for i in range(batch_start, batch_end):
        if i == fetch_offset:
            builder.skip(1)
        else:
            builder.append(key=None, value=b'msg', timestamp=None, headers=[])
    builder.close()
    memory_records = MemoryRecords(builder.buffer())
    records = Fetcher.PartitionRecords(fetch_offset, tp, memory_records)
    msgs = records.take()
    assert len(msgs) == batch_end - fetch_offset - 1
    assert msgs[0].offset == fetch_offset + 1
Test that messagesets are handle correctly
    when the fetch offset points to a message that has been compacted
    
test/test_fetcher.py