fix: send subscription Stars invoice directly
This commit is contained in:
1 parent
6dd685a6a5
commit
aaea5b6f58
7 files changed
+10
-62
No files matched your search
+3
-25
@@ -173,46 +173,24 @@ class ModeRoutingTests(unittest.IsolatedAsyncioTestCase):
|
||||
"subscription:renew",
|
||||
)
|
||||
|
||||
async def test_renew_callback_opens_purchase_prompt(self):
|
||||
async def test_renew_callback_sends_invoice_without_intermediate_message(self):
|
||||
message_bot = AsyncMock()
|
||||
message = Message(
|
||||
message_id=91,
|
||||
date=datetime.now(),
|
||||
chat=Chat(id=555, type="private"),
|
||||
).as_(message_bot)
|
||||
callback = SimpleNamespace(
|
||||
message=message,
|
||||
answer=AsyncMock(),
|
||||
)
|
||||
await bot.subscription_renew(callback, _StubState("subscription"))
|
||||
|
||||
callback.answer.assert_awaited_once_with()
|
||||
sent_call = message_bot.await_args
|
||||
if sent_call is None:
|
||||
self.fail("purchase prompt was not sent")
|
||||
sent = sent_call.args[0]
|
||||
self.assertIn("Продление подписки", sent.text)
|
||||
self.assertEqual(
|
||||
sent.reply_markup.inline_keyboard[0][0].callback_data,
|
||||
"subscription:buy",
|
||||
)
|
||||
|
||||
async def test_buy_callback_sends_invoice_for_clicking_user(self):
|
||||
message = Message(
|
||||
message_id=92,
|
||||
date=datetime.now(),
|
||||
chat=Chat(id=555, type="private"),
|
||||
).as_(AsyncMock())
|
||||
callback = SimpleNamespace(
|
||||
message=message,
|
||||
from_user=SimpleNamespace(id=42),
|
||||
answer=AsyncMock(),
|
||||
)
|
||||
with patch.object(bot, "_send_subscription_invoice", new=AsyncMock()) as send_invoice:
|
||||
await bot.subscription_buy(callback, _StubState("subscription"))
|
||||
await bot.subscription_renew(callback, _StubState("subscription"))
|
||||
|
||||
callback.answer.assert_awaited_once_with()
|
||||
send_invoice.assert_awaited_once_with(message, 42)
|
||||
message_bot.assert_not_awaited()
|
||||
|
||||
async def test_idea_command_generates_only_in_generation_mode(self):
|
||||
message = _StubMessage("/idea")
|
||||
|
||||
Reference in new issue
Block a user