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.

2.0 KB
Raw Blame
"""Keep rendered release-note links valid for both issues and PRs."""

# allow: no-sut-import — this invokes the release-notes CLI against fixtures.

from __future__ import annotations

import shutil
import subprocess
from pathlib import Path

import pytest


ROOT = Path(__file__).resolve().parents[2]
BASE = "https://github.com/LearningCircuit/local-deep-research"


@pytest.mark.skipif(
    shutil.which("towncrier") is None, reason="towncrier unavailable"
)
def test_towncrier_links_issue_and_pr_fragments_to_unified_github_route(
    tmp_path,
):
    # Build against synthetic fragments, never the real changelog.d: the
    # release consumes (deletes) those fragments, so asserting on them would
    # go red on main right after release. Only the repo's real
    # [tool.towncrier] config (pyproject.toml) is exercised.
    shutil.copy(ROOT / "pyproject.toml", tmp_path / "pyproject.toml")
    frag_dir = tmp_path / "changelog.d"
    frag_dir.mkdir()
    (frag_dir / "11111.bugfix.md").write_text("Fix reported in an issue.\n")
    (frag_dir / "22222.feature.md").write_text("Feature delivered by a PR.\n")
    (frag_dir / "+orphan-slug.misc.md").write_text("Fragment without a link.\n")

    result = subprocess.run(
        [
            "towncrier",
            "build",
            "--draft",
            "--version",
            "0.0.0",
            "--dir",
            str(tmp_path),
            "--config",
            str(tmp_path / "pyproject.toml"),
        ],
        check=True,
        capture_output=True,
        text=True,
        timeout=30,
    )
    notes = result.stdout

    # /issues/ resolves for both issue numbers and PR numbers; the previous
    # /pull/ template left issue-number fragments as broken links.
    for number in (11111, 22222):
        assert f"[#{number}]({BASE}/issues/{number})" in notes
    assert "/pull/" not in notes
    # The +slug fragment has no issue, so it renders its text with no link.
    assert "Fragment without a link." in notes
    assert "+orphan-slug" not in notes