mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 01:54:53 +00:00
refactor(handler): rename observers
Rename observers but with backward compatibility, relevant documentation
This commit is contained in:
parent
b097680f3c
commit
4124770b0e
21 changed files with 297 additions and 110 deletions
49
tests/test_dispatcher/test_deprecated.py
Normal file
49
tests/test_dispatcher/test_deprecated.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import pytest
|
||||
|
||||
from aiogram.dispatcher.event.observer import TelegramEventObserver
|
||||
from aiogram.dispatcher.router import Router
|
||||
|
||||
OBSERVERS = {
|
||||
"callback_query",
|
||||
"channel_post",
|
||||
"chosen_inline_result",
|
||||
"edited_channel_post",
|
||||
"edited_message",
|
||||
"errors",
|
||||
"inline_query",
|
||||
"message",
|
||||
"poll",
|
||||
"poll_answer",
|
||||
"pre_checkout_query",
|
||||
"shipping_query",
|
||||
"update",
|
||||
}
|
||||
|
||||
|
||||
def test_deprecated_handlers_name():
|
||||
from aiogram import __version__
|
||||
|
||||
minor_partial = int(__version__.split(".")[1])
|
||||
|
||||
if minor_partial >= 2:
|
||||
do_assert = pytest.raises(AttributeError)
|
||||
else:
|
||||
do_assert = pytest.warns(DeprecationWarning)
|
||||
|
||||
router = Router()
|
||||
|
||||
async def _(__):
|
||||
...
|
||||
|
||||
with do_assert:
|
||||
for decor in OBSERVERS:
|
||||
getattr(router, decor + "_handler")
|
||||
|
||||
assert all(
|
||||
isinstance(getattr(router, handler + "_handler"), TelegramEventObserver)
|
||||
for handler in OBSERVERS
|
||||
)
|
||||
|
||||
assert all(
|
||||
isinstance(getattr(router, handler), TelegramEventObserver) for handler in OBSERVERS
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue