mirror of
https://github.com/kuhyx/signal-bot.git
synced 2026-11-10 19:17:02 +01:00
"Wersja 0.1.7 «Callistus I»" told nobody whether Callistus was the fifteenth pope or the hundredth, and the changelog was the one place the ladder is actually read. pope_line() derives both facts from popes.json -- the ordinal, and the `reign` string exactly as the table spells it, so the one reigning pope keeps his single year instead of being padded into a range he never had. It appears in all four places a version is named: the group announcement (header and every block of a backlog), each section of DOCS-changelog.md, /healthz, and the !papiez caption, which now describes the release's pope in the same sentence it uses for every other one. The changelog's copy is checked rather than trusted, like the heading name already was: a test walks the raw file and compares each line against popes.json, so a hand-edited ordinal fails here instead of in a group. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017w1HZ3cZ7neL3rFdQ6VMBA
87 lines
2.7 KiB
Python
87 lines
2.7 KiB
Python
# 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"
|
|
"papież nr 2 z 267, pontyfikat 64-76\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)
|
|
|
|
|
|
def test_every_block_of_a_backlog_names_its_own_pope() -> None:
|
|
"""Two releases, two papacies -- the header's is not the whole ladder."""
|
|
message = render(LINUS, RELEASES)
|
|
assert "papież nr 1 z 267, pontyfikat 33-64" in message
|
|
assert "papież nr 2 z 267, pontyfikat 64-76" in message
|