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.7 KB
Raw Blame
"""Collection page data stays in HTML metadata rather than script source."""

import pytest
from bs4 import BeautifulSoup
from starlette.requests import Request

from local_deep_research.web.template_config import templates


@pytest.mark.parametrize(
    "template",
    ["pages/collection_details.html", "pages/collection_upload.html"],
)
@pytest.mark.parametrize(
    "collection_id",
    ["00000000-0000-4000-8000-000000000001", "ordinary ' \" & < > \\ π", ""],
    ids=["canonical-uuid", "punctuation", "empty"],
)
def test_collection_identifier_is_html_data(app, template, collection_id):
    request = Request(
        {
            "type": "http",
            "method": "GET",
            "path": "/library/collections/fixture",
            "root_path": "",
            "scheme": "http",
            "headers": [],
            "query_string": b"",
            "session": {},
            "app": app,
            "router": app.router,
            "server": ("testserver", 80),
        }
    )
    response = templates.TemplateResponse(
        request,
        template,
        {"collection_id": collection_id, "collection_name": "Fixture"},
    )
    document = BeautifulSoup(response.body, "html.parser")
    metadata = document.select('head meta[name="collection-id"]')
    assert len(metadata) == 1
    assert metadata[0]["content"] == collection_id
    assert set(metadata[0].attrs) == {"name", "content"}

    bootstraps = [
        script.get_text()
        for script in document.find_all("script", src=False)
        if "const COLLECTION_ID" in script.get_text()
    ]
    assert len(bootstraps) == 1
    if collection_id:
        assert collection_id not in bootstraps[0]