refactor: unify Telegram delivery and add quality checks
Some checks failed
quality / test (3.10) (push) Has been cancelled
quality / test (3.12) (push) Has been cancelled

This commit is contained in:
kandrusyak
2026-07-27 17:54:25 +03:00
parent c20d893255
commit 701cdd35d2
14 changed files with 123 additions and 82 deletions

View File

@@ -12,6 +12,7 @@ from assistant_bot.telegram_utils import (
escape_markdown_text,
render_markdown_chunks,
reply_markdown,
send_markdown,
typing_action,
)
@@ -55,6 +56,21 @@ class MarkdownRenderingTests(unittest.TestCase):
class MarkdownDeliveryTests(unittest.IsolatedAsyncioTestCase):
async def test_send_markdown_uses_the_shared_formatted_delivery(self) -> None:
sent_message = SimpleNamespace()
bot = SimpleNamespace(
send_message=AsyncMock(return_value=sent_message)
)
result = await send_markdown(bot, 42, "**Готово.**")
self.assertIs(result, sent_message)
bot.send_message.assert_awaited_once_with(
chat_id=42,
text="*Готово\\.*",
parse_mode=ParseMode.MARKDOWN_V2,
)
async def test_retries_plain_text_with_notice_when_telegram_rejects_markup(
self,
) -> None: