import asyncio

from log_analyzer.batch import async_batch_process


def test_batch_basic():
    items = [
        {"id": 1, "data": "hello", "priority": 1},
        {"id": 2, "data": "world", "priority": 2},
        {"id": 1, "data": "duplicate", "priority": 3},
    ]
    result = asyncio.run(async_batch_process(items))
    assert len(result) == 2
    assert result[0]["priority"] > result[1]["priority"]


def test_batch_large():
    """Production-scale batch — async endpoint is too slow on this."""
    items = []
    for i in range(50_000):
        items.append(
            {
                "id": i % 40_000,  # ~20% duplicates
                "data": f"payload-{i}",
                "priority": i % 100,
            }
        )
    result = asyncio.run(async_batch_process(items))
    assert len(result) == 40_000
