Test your Telegram bots easily
Project description
aiogram_bot_tester
Installation
Stable version:
pip install aiogram_bot_tester
Latest development version:
pip install git+https://github.com/samedit66/aiogram-bot-tester.git
What's that?
aiogram_bot_tester is a lightweight way to test aiogram bots offline, without real Telegram API calls. It helps you simulate updates, check bot responses, and keep tests deterministic, so bot logic can be covered with confidence even when the conversation flow is complex.
Quick example
import pytest
import aiogram
from aiogram import F
from aiogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup, Message
from aiogram_bot_tester import BotTester
router = aiogram.Router()
@router.message(aiogram.filters.CommandStart())
async def cmd_start(message: Message) -> None:
await message.answer(
"Hello! Press Continue or send me your name.",
reply_markup=InlineKeyboardMarkup(
inline_keyboard=[
[InlineKeyboardButton(text="Continue", callback_data="continue")]
]
),
)
@router.message(F.text)
async def echo_name(message: Message) -> None:
await message.answer(f"Nice to meet you, {message.text}!")
@router.callback_query(F.data == "continue")
async def on_continue(callback: CallbackQuery) -> None:
await callback.message.answer("Please send your name.")
@pytest.mark.asyncio
async def test_flow() -> None:
tester = BotTester.from_routers(router)
response = await tester.start()
assert response.contains_text("Hello")
assert response.has_button("Continue")
response = await tester.tap_button("Continue")
assert response.contains_text("Please send your name.")
response = await tester.send_message("Bob")
assert response.contains_text("Nice to meet you, Bob!")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiogram_bot_tester-1.0.1.tar.gz.
File metadata
- Download URL: aiogram_bot_tester-1.0.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5d9ad93249d47d3ac13263e6a1cbd629f94f9d5e626af8b53b5e472a4d0af0a
|
|
| MD5 |
a094891971f2b21bcc89284c41514815
|
|
| BLAKE2b-256 |
7fc5787f86f424484a2f4870363890c2308e7233f06d3fd6e146f961c22046bc
|
File details
Details for the file aiogram_bot_tester-1.0.1-py3-none-any.whl.
File metadata
- Download URL: aiogram_bot_tester-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.12 {"installer":{"name":"uv","version":"0.11.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6899cd8f5684fdeefbd6c32f8bd7ce9e40cc1c90b8077ff7b80de9991f1ed3f5
|
|
| MD5 |
f0f85dfd0cec948326b2ad77305e317e
|
|
| BLAKE2b-256 |
d6200febffb3ff29d39b66e5b06ede1912213c6260bd61060242e5805d9745c6
|