add formating

This commit is contained in:
kandrusyak
2026-07-27 17:14:07 +03:00
parent 7b7ff51d0f
commit 275eca8dc5
10 changed files with 628 additions and 157 deletions

View File

@@ -5,11 +5,12 @@ from types import SimpleNamespace
from typing import Any
from unittest.mock import AsyncMock
from telegram.constants import ChatType
from telegram.constants import ChatType, ParseMode
from telegram.ext import ApplicationHandlerStop
from assistant_bot.auth import authentication_guard
from assistant_bot.storage import AssistantStorage
from assistant_bot.telegram_utils import render_markdown_chunks
class AuthenticationGuardTests(unittest.IsolatedAsyncioTestCase):
@@ -47,8 +48,12 @@ class AuthenticationGuardTests(unittest.IsolatedAsyncioTestCase):
await authentication_guard(update, context)
self.assertTrue(self.storage.is_user_authorized(42))
rendered = render_markdown_chunks(
"✅ **Пароль принят.** Доступ открыт — повторно вводить его не нужно."
)[0][0]
update.effective_message.reply_text.assert_awaited_once_with(
"Пароль принят. Доступ открыт — повторно вводить его не нужно."
rendered,
parse_mode=ParseMode.MARKDOWN_V2,
)
async def test_wrong_password_does_not_authorize_user(self) -> None:
@@ -58,8 +63,12 @@ class AuthenticationGuardTests(unittest.IsolatedAsyncioTestCase):
await authentication_guard(update, context)
self.assertFalse(self.storage.is_user_authorized(42))
rendered = render_markdown_chunks(
"🔐 **Неверный пароль.** Попробуй ещё раз."
)[0][0]
update.effective_message.reply_text.assert_awaited_once_with(
"Неверный пароль. Попробуй еще раз."
rendered,
parse_mode=ParseMode.MARKDOWN_V2,
)
async def test_authorized_user_passes_guard(self) -> None: