From 13230e3fe2ed9f7cd19d32dceb13dc9211965be4 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 20 Oct 2026 21:29:44 +0200 Subject: [PATCH] fix: simplify subscription payment messages --- bot.py | 2 +- tests/test_payments.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index a0f9fe7..244538c 100644 --- a/bot.py +++ b/bot.py @@ -433,7 +433,7 @@ async def confirm_development_payment(callback: CallbackQuery) -> None: await callback.answer("Dev-оплата подтверждена.") if isinstance(callback.message, Message): await callback.message.edit_reply_markup(reply_markup=None) - await callback.message.answer(f"Подписка активна\nЗакончится через {days_left} дн.") + await callback.message.edit_text(f"Подписка активна\nЗакончится через {days_left} дн.") @router.message(CommandStart()) diff --git a/tests/test_payments.py b/tests/test_payments.py index a610b80..f7343e5 100644 --- a/tests/test_payments.py +++ b/tests/test_payments.py @@ -1,4 +1,5 @@ import asyncio +from datetime import datetime import os import tempfile import unittest @@ -6,7 +7,7 @@ from unittest.mock import AsyncMock, patch from types import SimpleNamespace -from aiogram.types import LabeledPrice, SuccessfulPayment +from aiogram.types import Chat, LabeledPrice, Message, SuccessfulPayment import bot import payments @@ -233,7 +234,7 @@ class SubscribeCommandTests(unittest.IsolatedAsyncioTestCase): callback = AsyncMock() callback.data = "dev_paid:42:10" callback.from_user = SimpleNamespace(id=42) - callback.message = None + callback.message = Message(message_id=1, date=datetime.now(), chat=Chat(id=555, type="private")).as_(AsyncMock()) db = _db() user_store.ensure_subscription(42, db) with ( @@ -242,8 +243,10 @@ class SubscribeCommandTests(unittest.IsolatedAsyncioTestCase): patch.object(bot.asyncio, "to_thread", new=AsyncMock(return_value=32)) as to_thread, ): await bot.confirm_development_payment(callback) - os.unlink(db) - self.assertEqual(to_thread.await_args.args, (user_store.activate_subscription_days, 42, 10)) + db_row = user_store.subscription_row(42, db) + patch_calls = [call for call in to_thread.await_args_list if call.args[0] is user_store.activate_subscription_days] + self.assertEqual(patch_calls[0].args[1:], (42, 10)) + self.assertIsNotNone(db_row) callback.answer.assert_awaited_once_with("Dev-оплата подтверждена.") async def test_dev_confirmation_rejects_other_user(self):