test: the render tests get their own file, under the 250-line cap

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Krzysztof Rudnicki 2026-08-30 21:34:23 +02:00
parent dc642b8a1f
commit da6e69cd44

View File

@ -0,0 +1,78 @@
# Copyright (c) 2026 Krzysztof Rudnicki. MIT licence.
"""What a release announcement says: the Latin name, the article, the ladder."""
from __future__ import annotations
from signal_bot.announce import render
from signal_bot.changelog import parse
from signal_bot.versioning import pope_for
DOCUMENT = """\
## 0.0.1 — Linus
- druga zmiana
## 0.0.0 — Petrus
- pierwsza zmiana
"""
RELEASES = parse(DOCUMENT)
PETRUS = pope_for(1)
LINUS = pope_for(2)
def test_a_single_release_is_rendered_flat() -> None:
"""The header already names it; a per-release block would just repeat it."""
message = render(LINUS, RELEASES[1:])
assert message == (
"Wersja 0.0.1 «Linus» wydana\n"
"https://pl.wikipedia.org/wiki/Linus_%28papie%C5%BC%29\n"
"Changelog:\n- druga zmiana"
)
def test_a_long_backlog_is_capped_and_says_so() -> None:
"""A group added years from now must not be handed 200 releases."""
document = "\n\n".join(
f"## {v} — Pope{i}\n\n- zmiana {i}"
for i, v in enumerate(
[
"0.0.0",
"0.0.1",
"0.0.2",
"0.0.3",
"0.0.4",
"0.0.5",
"0.0.6",
"0.0.7",
"0.1.0",
"0.1.1",
"0.1.2",
"0.1.3",
]
)
)
message = render(pope_for(12), parse(document))
assert "(pominieto 2 starszych wersji)" in message
assert "zmiana 0" not in message
assert "zmiana 11" in message
def test_a_block_heading_ignores_the_name_typed_in_the_document() -> None:
"""The heading says Pope3; popes.json is what the group is actually told."""
message = render(pope_for(12), parse("## 0.0.2 — Pope3\n\n- x\n\n## 0.0.3 — Pope4\n\n- y"))
assert "0.0.2 «Anacletus»" in message
assert "0.0.3 «Clemens I»" in message
assert "Pope3" not in message
def test_render_names_the_version_and_lists_every_pending_line() -> None:
message = render(LINUS, RELEASES)
assert message.startswith("Wersja 0.0.1 «Linus» wydana")
assert "- pierwsza zmiana" in message
assert "- druga zmiana" in message
def test_render_links_the_polish_article() -> None:
"""The same article !papież posts, built from the disambiguated title."""
assert "https://pl.wikipedia.org/wiki/Piotr_Aposto%C5%82" in render(PETRUS, RELEASES)