mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Cover base filter
This commit is contained in:
parent
cd12b54ec2
commit
fa42dcdce2
2 changed files with 32 additions and 1 deletions
30
tests/test_dispatcher/test_filters/test_base.py
Normal file
30
tests/test_dispatcher/test_filters/test_base.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from typing import Awaitable
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from asynctest import CoroutineMock
|
||||
|
||||
from aiogram.dispatcher.filters.base import BaseFilter
|
||||
|
||||
|
||||
class MyFilter(BaseFilter):
|
||||
foo: str
|
||||
|
||||
async def __call__(self, event: str):
|
||||
return
|
||||
|
||||
|
||||
class TestBaseFilter:
|
||||
@pytest.mark.asyncio
|
||||
async def test_awaitable(self):
|
||||
my_filter = MyFilter(foo="bar")
|
||||
|
||||
assert isinstance(my_filter, Awaitable)
|
||||
|
||||
with patch(
|
||||
"tests.test_dispatcher.test_filters.test_base.MyFilter.__call__",
|
||||
new_callable=CoroutineMock,
|
||||
) as mocked_call:
|
||||
call = my_filter(event="test")
|
||||
await call
|
||||
mocked_call.assert_awaited_with(event="test")
|
||||
Loading…
Add table
Add a link
Reference in a new issue