Skip to main content

Test your Telegram bots easily

Project description

aiogram_bot_tester

aiogram telegram status python PyPI Downloads

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

aiogram_bot_tester-1.0.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiogram_bot_tester-1.0.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

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

Hashes for aiogram_bot_tester-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b5d9ad93249d47d3ac13263e6a1cbd629f94f9d5e626af8b53b5e472a4d0af0a
MD5 a094891971f2b21bcc89284c41514815
BLAKE2b-256 7fc5787f86f424484a2f4870363890c2308e7233f06d3fd6e146f961c22046bc

See more details on using hashes here.

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

Hashes for aiogram_bot_tester-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6899cd8f5684fdeefbd6c32f8bd7ce9e40cc1c90b8077ff7b80de9991f1ed3f5
MD5 f0f85dfd0cec948326b2ad77305e317e
BLAKE2b-256 d6200febffb3ff29d39b66e5b06ede1912213c6260bd61060242e5805d9745c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page