mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Add tests for content types
This commit is contained in:
parent
8df6c345c3
commit
6ee05fb901
6 changed files with 391 additions and 10 deletions
|
|
@ -3,6 +3,7 @@ import functools
|
|||
from typing import Any, Awaitable, Callable, Dict, NoReturn, Union
|
||||
|
||||
import pytest
|
||||
|
||||
from aiogram.api.types import Chat, Message, User
|
||||
from aiogram.dispatcher.event.handler import HandlerObject
|
||||
from aiogram.dispatcher.event.observer import EventObserver, SkipHandler, TelegramEventObserver
|
||||
|
|
|
|||
24
tests/test_dispatcher/test_filters/test_content_types.py
Normal file
24
tests/test_dispatcher/test_filters/test_content_types.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from aiogram.dispatcher.filters import ContentTypesFilter
|
||||
|
||||
|
||||
class TestContentTypesFilter:
|
||||
def test_validator_empty(self):
|
||||
filter_ = ContentTypesFilter()
|
||||
assert filter_.content_types == ["text"]
|
||||
|
||||
def test_validator_empty_list(self):
|
||||
filter_ = ContentTypesFilter(content_types=[])
|
||||
assert filter_.content_types == ["text"]
|
||||
|
||||
@pytest.mark.parametrize("values", [["text", "photo"], ["sticker"]])
|
||||
def test_validator_with_values(self, values):
|
||||
filter_ = ContentTypesFilter(content_types=values)
|
||||
assert filter_.content_types == values
|
||||
|
||||
@pytest.mark.parametrize("values", [["test"], ["text", "test"], ["TEXT"]])
|
||||
def test_validator_with_bad_values(self, values):
|
||||
with pytest.raises(ValidationError):
|
||||
ContentTypesFilter(content_types=values)
|
||||
Loading…
Add table
Add a link
Reference in a new issue