A library for testing your bots on aiogram
Project description
Aiogram Tests
aiogram_tests is a testing library for bots written on aiogram
📦 Installation
pip install aiogram-testing
The import name stays aiogram_tests:
from aiogram_tests import MockedRequester
📚 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 MockedRequester
from aiogram_tests.handler import MessageHandler
from aiogram_tests.types.dataset import MESSAGE
@pytest.mark.asyncio
async def test_echo():
request = MockedRequester(MessageHandler(echo))
calls = await request.query(message=MESSAGE.as_object(text="Hello, Bot!"))
answer_message = calls.send_message.fetchone()
assert answer_message.text == "Hello, Bot!"
▶️ More examples
Project details
Release history Release notifications | RSS feed
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_testing-1.1.0.tar.gz.
File metadata
- Download URL: aiogram_testing-1.1.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37f8d83177cb783b9b438f5d88d8004767cab4805dd0fa5b07df2ffe145883fa
|
|
| MD5 |
ea867912aefdd890cf0c79aca1ffaf56
|
|
| BLAKE2b-256 |
9349703a3be9c1e8ba047ac2d5a03d45ca824c57acbe02fd338b1d6850c2022c
|
Provenance
The following attestation bundles were made for aiogram_testing-1.1.0.tar.gz:
Publisher:
release.yml on k0te1ch/aiogram_tests
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiogram_testing-1.1.0.tar.gz -
Subject digest:
37f8d83177cb783b9b438f5d88d8004767cab4805dd0fa5b07df2ffe145883fa - Sigstore transparency entry: 1673124302
- Sigstore integration time:
-
Permalink:
k0te1ch/aiogram_tests@09c71193e1f8c2e7fa70db600e093d76f53854b4 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/k0te1ch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@09c71193e1f8c2e7fa70db600e093d76f53854b4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiogram_testing-1.1.0-py3-none-any.whl.
File metadata
- Download URL: aiogram_testing-1.1.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46b56d08a7f0890ecb5e846b63f18a607c956d6c3a3a3b5fd173c2c2db5e5780
|
|
| MD5 |
fea7323dd89553043481f67d139fb5e8
|
|
| BLAKE2b-256 |
8d63eb5d30dc9d0c89ca4f5f187d1820160d3e6861792f20988649fec756b9bf
|
Provenance
The following attestation bundles were made for aiogram_testing-1.1.0-py3-none-any.whl:
Publisher:
release.yml on k0te1ch/aiogram_tests
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiogram_testing-1.1.0-py3-none-any.whl -
Subject digest:
46b56d08a7f0890ecb5e846b63f18a607c956d6c3a3a3b5fd173c2c2db5e5780 - Sigstore transparency entry: 1673124343
- Sigstore integration time:
-
Permalink:
k0te1ch/aiogram_tests@09c71193e1f8c2e7fa70db600e093d76f53854b4 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/k0te1ch
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@09c71193e1f8c2e7fa70db600e093d76f53854b4 -
Trigger Event:
push
-
Statement type: