from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def read(path: str) -> str:
    return (ROOT / path).read_text(encoding="utf-8")


def test_audit_script_does_not_shadow_openrouter_key_when_use_llm():
    script = read("scripts/audit_task_reply_suggestions.py")
    assert "Do not inject a dummy" in script
    assert "args.use_llm" in script
    assert "os.environ.pop(\"OPENROUTER_API_KEY\", None)" in script


def test_audit_script_keeps_placeholder_only_for_no_llm_mode():
    script = read("scripts/audit_task_reply_suggestions.py")
    assert "os.environ.setdefault(\"OPENROUTER_API_KEY\", \"not-used-by-task-reply-audit\")" in script
    no_llm_section = script.split("else:", 1)[1]
    assert "not-used-by-task-reply-audit" in no_llm_section


def test_release_notes_document_auth_hotfix():
    notes = read("RELEASE_NOTES_v4928_1_5_5.md")
    assert "Audit LLM Auth Hotfix" in notes
    assert "Missing Authentication header" in notes
