214
Some checks failed
CI / Lint (ruff + mypy) (push) Failing after 32s
CI / Run tests (push) Has been skipped
CI / Docker build test (push) Successful in 11s

This commit is contained in:
2026-04-02 22:03:20 +07:00
parent 8be26418b1
commit ddebe03f15
3 changed files with 82 additions and 56 deletions

View File

@@ -1,7 +1,7 @@
from session_bot.render import build_channel_text
def test_build_channel_text_includes_phrase_and_status() -> None:
def test_build_channel_text_includes_phrase() -> None:
config = {
"template_text": "{{hidden_link}}\nheader\n\n{{actors}}",
"hidden_link_url": "https://example.com/image.png",
@@ -18,15 +18,13 @@ def test_build_channel_text_includes_phrase_and_status() -> None:
"phrases": {"open": "принимает тейки"},
}
],
"status_labels": {"open": "исполняет роль", "backstage": "в закулисье"},
}
state = {"actors": {"astat": {"status": "open", "phrase": "готов к игре"}}}
text = build_channel_text(config, state)
assert '<a href="https://example.com/image.png">' in text
assert text.startswith('<a href="https://example.com/image.png">')
assert '<a href="https://t.me/example"><b>ASTAT</b></a>' in text
assert "исполняет роль" in text
assert "готов к игре" in text
@@ -58,9 +56,8 @@ def test_build_channel_text_supports_per_actor_placeholders() -> None:
},
],
}
state = {"actors": {}}
text = build_channel_text(config, state)
text = build_channel_text(config, {"actors": {}})
assert text.count("<b>ASTAT</b>") == 1
assert text.count("<b>MARI</b>") == 1
@@ -86,10 +83,31 @@ def test_build_channel_text_inlines_actor_fragment_without_duplication() -> None
}
],
}
state = {"actors": {}}
text = build_channel_text(config, state)
text = build_channel_text(config, {"actors": {}})
assert text.count("<b>LIEBE</b>") == 1
assert "she/her в закулисье." in text
assert "в закулисье." in text
def test_plain_links_are_converted_to_html() -> None:
config = {
"template_text": "rules (https://example.com)\n\n{{actors}}",
"actors": [
{
"key": "astat",
"display_name": "ASTAT",
"display_html": "<b>ASTAT</b>",
"link": "https://t.me/astat",
"pronouns": "he/him",
"meta_html": " he/him ",
"emoji": "🌟",
"default_status": "backstage",
"phrases": {"backstage": "в закулисье."},
}
],
}
text = build_channel_text(config, {"actors": {}})
assert '<a href="https://example.com">rules</a>' in text