Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

1.4 KB
Raw Blame
"""Smoke tests for the run_parallel_searches helper.

These verify the contract documented in the module:

* empty input short-circuits to an empty list
* non-empty input returns one ``(query, payload)`` tuple per query
* ``search_fn`` may return any payload type (list, dict, etc.)
"""

from local_deep_research.advanced_search_system.parallel_search import (
    run_parallel_searches,
)


def test_empty_queries_returns_empty_list():
    assert run_parallel_searches([], lambda q: [q]) == []


def test_returns_one_tuple_per_query():
    results = run_parallel_searches(["a", "b", "c"], lambda q: [q.upper()])
    assert sorted(results) == [("a", ["A"]), ("b", ["B"]), ("c", ["C"])]


def test_payload_can_be_dict():
    results = run_parallel_searches(
        ["x", "y"], lambda q: {"question": q, "results": [q]}
    )
    assert sorted(results) == [
        ("x", {"question": "x", "results": ["x"]}),
        ("y", {"question": "y", "results": ["y"]}),
    ]


def test_max_workers_passed_through():
    # Smoke test: helper accepts max_workers without error.
    results = run_parallel_searches(["a", "b", "c"], lambda q: q, max_workers=2)
    assert sorted(results) == [("a", "a"), ("b", "b"), ("c", "c")]


def test_default_max_workers():
    # When max_workers is None, defaults to len(queries). Smoke test only.
    results = run_parallel_searches(["a"], lambda q: q)
    assert results == [("a", "a")]