Metadata-Version: 2.4
Name: aiogram-testing
Version: 1.1.0
Summary: A library for testing your bots on aiogram
License: MIT
Author: k0te1ch
Author-email: khvostov40@gmail.com
Requires-Python: >=3.12,<3.15
Classifier: Framework :: AsyncIO
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Testing
Requires-Dist: aiogram (>=3.28,<4.0)
Project-URL: Homepage, https://github.com/k0te1ch/aiogram_tests
Project-URL: Repository, https://github.com/k0te1ch/aiogram_tests
Description-Content-Type: text/markdown

# Aiogram Tests

***aiogram_tests*** is a testing library for bots written on [aiogram]("https://github.com/aiogram/aiogram")</a>

## 📦 Installation

```bash
pip install aiogram-testing
```

The import name stays `aiogram_tests`:

```python
from aiogram_tests import MockedRequester
```

## 📚 Simple examples

### Simple handler test

#### Simple bot

```python
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

```python
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]("https://github.com/aiogram-tests/aiogram_tests/tree/master/examples") examples

