mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Rework event propagation to routers mechanism. Fixed compatibility with Python 3.10 syntax (match keyword)
This commit is contained in:
parent
779fe6aa4a
commit
a2bafb27e4
11 changed files with 91 additions and 29 deletions
|
|
@ -4,7 +4,7 @@ from typing import Any, Awaitable, Callable, Dict, NoReturn, Union
|
|||
|
||||
import pytest
|
||||
|
||||
from aiogram.dispatcher.event.bases import UNHANDLED, SkipHandler
|
||||
from aiogram.dispatcher.event.bases import REJECTED, SkipHandler
|
||||
from aiogram.dispatcher.event.handler import HandlerObject
|
||||
from aiogram.dispatcher.event.telegram import TelegramEventObserver
|
||||
from aiogram.dispatcher.filters.base import BaseFilter
|
||||
|
|
@ -262,5 +262,5 @@ class TestTelegramEventObserver:
|
|||
r1.message.register(handler)
|
||||
r2.message.register(handler)
|
||||
|
||||
assert await r1.message.trigger(None) is UNHANDLED
|
||||
assert await r1.message.trigger(None) is REJECTED
|
||||
assert await r2.message.trigger(None) is None
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ from aiogram.dispatcher.filters import ExceptionMessageFilter, ExceptionTypeFilt
|
|||
class TestExceptionMessageFilter:
|
||||
@pytest.mark.parametrize("value", ["value", re.compile("value")])
|
||||
def test_converter(self, value):
|
||||
obj = ExceptionMessageFilter(match=value)
|
||||
assert isinstance(obj.match, re.Pattern)
|
||||
obj = ExceptionMessageFilter(pattern=value)
|
||||
assert isinstance(obj.pattern, re.Pattern)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_match(self):
|
||||
obj = ExceptionMessageFilter(match="KABOOM")
|
||||
obj = ExceptionMessageFilter(pattern="KABOOM")
|
||||
|
||||
result = await obj(Exception())
|
||||
assert not result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue