From 03d56b1f843011c8d4a3196fae0dcbe57b0fa14e Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sat, 25 Jun 2022 17:52:46 +0300 Subject: [PATCH] Added tests, fixed ForceReply --- aiogram/types/force_reply.py | 4 +- .../test_methods/test_create_invoice_link.py | 43 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/test_api/test_methods/test_create_invoice_link.py diff --git a/aiogram/types/force_reply.py b/aiogram/types/force_reply.py index af5c6299..55f1b6c9 100644 --- a/aiogram/types/force_reply.py +++ b/aiogram/types/force_reply.py @@ -2,6 +2,8 @@ from __future__ import annotations from typing import Optional +from pydantic import Field + from .base import MutableTelegramObject @@ -19,7 +21,7 @@ class ForceReply(MutableTelegramObject): Source: https://core.telegram.org/bots/api#forcereply """ - force_reply: bool + force_reply: bool = Field(True, const=True) """Shows reply interface to the user, as if they manually selected the bot's message and tapped 'Reply'""" input_field_placeholder: Optional[str] = None """*Optional*. The placeholder to be shown in the input field when the reply is active; 1-64 characters""" diff --git a/tests/test_api/test_methods/test_create_invoice_link.py b/tests/test_api/test_methods/test_create_invoice_link.py new file mode 100644 index 00000000..2a3e16ac --- /dev/null +++ b/tests/test_api/test_methods/test_create_invoice_link.py @@ -0,0 +1,43 @@ +import pytest + +from aiogram.methods import CreateInvoiceLink, Request +from aiogram.types import LabeledPrice +from tests.mocked_bot import MockedBot + + +class TestCreateInvoiceLink: + @pytest.mark.asyncio + async def test_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + CreateInvoiceLink, ok=True, result="https://t.me/invoice/example" + ) + + response: str = await CreateInvoiceLink( + title="test", + description="test", + payload="test", + provider_token="test", + currency="BTC", + prices=[LabeledPrice(label="Test", amount=1)], + ) + request: Request = bot.get_request() + assert request.method == "createInvoiceLink" + assert response == prepare_result.result + + @pytest.mark.asyncio + async def test_bot_method(self, bot: MockedBot): + prepare_result = bot.add_result_for( + CreateInvoiceLink, ok=True, result="https://t.me/invoice/example" + ) + + response: str = await bot.create_invoice_link( + title="test", + description="test", + payload="test", + provider_token="test", + currency="BTC", + prices=[LabeledPrice(label="Test", amount=1)], + ) + request: Request = bot.get_request() + assert request.method == "createInvoiceLink" + assert response == prepare_result.result