More class based handlers

This commit is contained in:
Alex Root Junior 2020-01-21 23:33:44 +02:00
parent b144332287
commit 895b727ddf
24 changed files with 506 additions and 30 deletions

View file

@ -0,0 +1,25 @@
from typing import Any
import pytest
from aiogram.api.types import PreCheckoutQuery, User
from aiogram.dispatcher.handler import PreCheckoutQueryHandler
class TestPreCheckoutQueryHandler:
@pytest.mark.asyncio
async def test_attributes_aliases(self):
event = PreCheckoutQuery(
id="query",
from_user=User(id=42, is_bot=False, first_name="Test"),
currency="BTC",
total_amount=7,
invoice_payload="payload",
)
class MyHandler(PreCheckoutQueryHandler):
async def handle(self) -> Any:
assert self.event == event
assert self.from_user == self.event.from_user
return True
assert await MyHandler(event)