refactor: unify Telegram delivery and add quality checks
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user