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.6 KB
Raw Blame
"""The news page strategy dropdown needs {name,label} dicts.

news.html renders <option value="{{ s.name }}">{{ s.label }}</option>, so
it needs the dicts get_available_strategies returns (the source main used).
The FastAPI port hardcoded a plain string list with non-existent names
("topic_based", "news_aggregation", ...), so every option rendered blank
with an empty value.
"""

from unittest.mock import patch

from starlette.requests import Request


def _dummy_request():
    return Request(
        {
            "type": "http",
            "method": "GET",
            "path": "/news/",
            "headers": [],
            "session": {},
        }
    )


def _news_page_context():
    from local_deep_research.web.routers import news_pages

    captured = {}

    def fake_template_response(request, name, context, **kw):
        captured["context"] = context
        return "ok"

    with patch.object(
        news_pages.templates,
        "TemplateResponse",
        side_effect=fake_template_response,
    ):
        news_pages.news_page(_dummy_request(), username="alice")
    return captured["context"]


def test_strategies_are_objects_with_name_and_label():
    strategies = _news_page_context()["strategies"]

    assert strategies
    for s in strategies:
        assert isinstance(s, dict)
        assert "name" in s and "label" in s


def test_strategy_names_are_real_hyphenated_ids():
    names = {s["name"] for s in _news_page_context()["strategies"]}

    assert "source-based" in names
    # The bogus hardcoded names are gone.
    assert "topic_based" not in names
    assert "news_aggregation" not in names