How to use aiogram - 10 common examples

To help you get started, we’ve selected a few aiogram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aiogram / aiogram / tests / test_utils / test_helper.py View on Github external
def test_items_are_ordered(self):
        class MyOrderedHelper(OrderedHelper):
            A = Item()
            D = Item()
            C = Item()
            B = Item()

        assert MyOrderedHelper.all() == ["A", "D", "C", "B"]
github aiogram / aiogram / tests / test_utils / test_helper.py View on Github external
def test_items_are_ordered(self):
        class MyOrderedHelper(OrderedHelper):
            A = Item()
            D = Item()
            C = Item()
            B = Item()

        assert MyOrderedHelper.all() == ["A", "D", "C", "B"]
github aiogram / aiogram / tests / test_api / test_methods / test_stop_message_live_location.py View on Github external
async def test_method(self, bot: MockedBot):
        prepare_result = bot.add_result_for(StopMessageLiveLocation, ok=True, result=True)

        response: Union[Message, bool] = await StopMessageLiveLocation(
            inline_message_id="inline message id"
        )
        request: Request = bot.get_request()
        assert request.method == "stopMessageLiveLocation"
        assert response == prepare_result.result
github aiogram / aiogram / tests / test_api / test_methods / test_edit_message_caption.py View on Github external
async def test_method(self, bot: MockedBot):
        prepare_result = bot.add_result_for(
            EditMessageCaption,
            ok=True,
            result=Message(
                message_id=42,
                date=datetime.datetime.now(),
                text="text",
                chat=Chat(id=42, type="private"),
            ),
        )

        response: Union[Message, bool] = await EditMessageCaption()
        request: Request = bot.get_request()
        assert request.method == "editMessageCaption"
        assert response == prepare_result.result
github aiogram / aiogram / tests / test_dispatcher / test_filters / test_command.py View on Github external
                Message(
                    message_id=42,
                    date=datetime.datetime.now(),
                    text="/test",
                    chat=Chat(id=42, type="private"),
                    from_user=User(id=42, is_bot=False, first_name="Test"),
                ),
                True,
            ],
        ],
    )
    async def test_call(self, message: Message, result: bool, bot: MockedBot):
        command = Command(commands=["test"])
        assert bool(await command(message=message, bot=bot)) is result
github aiogram / aiogram / tests / test_api / test_methods / test_edit_message_text.py View on Github external
async def test_bot_method(self, bot: MockedBot):
        prepare_result = bot.add_result_for(EditMessageText, ok=True, result=True)

        response: Union[Message, bool] = await bot.edit_message_text(
            chat_id=42, inline_message_id="inline message id", text="text"
        )
        request: Request = bot.get_request()
        assert request.method == "editMessageText"
        assert response == prepare_result.result
github aiogram / aiogram / tests / test_api / test_methods / test_send_message.py View on Github external
async def test_bot_method(self, bot: MockedBot):
        prepare_result = bot.add_result_for(
            SendMessage,
            ok=True,
            result=Message(
                message_id=42,
                date=datetime.datetime.now(),
                text="test",
                chat=Chat(id=42, type="private"),
            ),
        )

        response: Message = await bot.send_message(chat_id=42, text="test")
        request: Request = bot.get_request()
        assert request.method == "sendMessage"
        assert response == prepare_result.result
github aiogram / aiogram / tests / test_api / test_methods / test_send_invoice.py View on Github external
async def test_bot_method(self, bot: MockedBot):
        prepare_result = bot.add_result_for(
            SendInvoice,
            ok=True,
            result=Message(
                message_id=42,
                date=datetime.datetime.now(),
                invoice=Invoice(
                    title="test",
                    description="test",
                    start_parameter="brilliant",
                    currency="BTC",
                    total_amount=1,
                ),
                chat=Chat(id=42, type="private"),
            ),
        )

        response: Message = await bot.send_invoice(
            chat_id=42,
            title="test",
github aiogram / aiogram / tests / test_utils / test_helper.py View on Github external
def test_list_items_are_ordered(self):
        class MyOrderedHelper(OrderedHelper):
            A = ListItem()
            D = ListItem()
            C = ListItem()
            B = ListItem()

        assert MyOrderedHelper.all() == ["A", "D", "C", "B"]
github aiogram / aiogram / tests / test_utils / test_helper.py View on Github external
def test_list_items_are_ordered(self):
        class MyOrderedHelper(OrderedHelper):
            A = ListItem()
            D = ListItem()
            C = ListItem()
            B = ListItem()

        assert MyOrderedHelper.all() == ["A", "D", "C", "B"]