Skip to main content

Aiogram Tests

aiogram_tests is a testing library for bots written on aiogram

📚 Simple examples

Simple handler test

Simple bot:

from aiogram import Bot, Dispatcher, types
from aiogram.fsm.context import FSMContext

# Please, keep your bot tokens on environments, this code only example
bot = Bot('123456789:AABBCCDDEEFFaabbccddeeff-1234567890')
dp = Dispatcher()


@dp.message()
async def echo(message: types.Message, state: FSMContext) -> None:
    await message.answer(message.text)


if __name__ == '__main__':
    dp.run_polling(bot)

Test cases:

import pytest

from bot import echo

from aiogram_tests import MockedBot
from aiogram_tests.handler import MessageHandler
from aiogram_tests.types.dataset import MESSAGE


@pytest.mark.asyncio
async def test_echo():
    request = MockedBot(MessageHandler(echo))
    calls = await request.query(message=MESSAGE.as_object(text="Hello, Bot!"))
    answer_message = calls.send_messsage.fetchone()
    assert answer_message.text == "Hello, Bot!"

▶️ More examples

Metadata

Release files for aiogram-tests 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiogram-tests 1.0.3
File Size Uploaded Provenance Actions
aiogram_tests-1.0.3.tar.gz 10.6 kB Without provenance Details for aiogram_tests-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiogram-tests 1.0.3
File Interpreter ABI Platform Actions
aiogram_tests-1.0.3-py3-none-any.whl Python 3 none any Details for aiogram_tests-1.0.3-py3-none-any.whl

Total release size: 22.8 kB

Release files / aiogram_tests-1.0.3.tar.gz

Download URL aiogram_tests-1.0.3.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cdc78e9a65e205a744e944361a844c0f764f7777718dde087821000d49d354b3
BLAKE2b-256 checksum
How to use checksums
460e5cd670e9a05fb1b66d1b860b500784c352758f618e5171ac6de88185e94a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Release files / aiogram_tests-1.0.3-py3-none-any.whl

Download URL aiogram_tests-1.0.3-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b92fc4dbb652ed115bbcef08d2e020a8e86e575217fb44876d926b5cd681aca0
BLAKE2b-256 checksum
How to use checksums
8a892537d3596abba90c09c977cb921b2c9d1013df8a1250761cf5d26c5605c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.8

Security for aiogram-tests 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page