mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Added MagicData filter
This commit is contained in:
parent
2d21cb22f1
commit
3f2bcbd8d1
3 changed files with 100 additions and 14 deletions
30
tests/test_dispatcher/test_filters/test_magic_data.py
Normal file
30
tests/test_dispatcher/test_filters/test_magic_data.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import pytest
|
||||
from magic_filter import AttrDict
|
||||
|
||||
from aiogram import F
|
||||
from aiogram.dispatcher.filters import MagicData
|
||||
from aiogram.types import Update
|
||||
|
||||
|
||||
class TestMagicDataFilter:
|
||||
@pytest.mark.asyncio
|
||||
async def test_call(self):
|
||||
called = False
|
||||
|
||||
def check(value):
|
||||
nonlocal called
|
||||
called = True
|
||||
|
||||
assert isinstance(value, AttrDict)
|
||||
assert value[0] == "foo"
|
||||
assert value[1] == "bar"
|
||||
assert value["spam"] is True
|
||||
assert value.spam is True
|
||||
return value
|
||||
|
||||
f = MagicData(magic_data=F.func(check))
|
||||
result = await f(Update(update_id=123), "foo", "bar", spam=True)
|
||||
|
||||
assert called
|
||||
assert isinstance(result, bool)
|
||||
assert result
|
||||
Loading…
Add table
Add a link
Reference in a new issue