# 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