mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Allow to use regular values as the same with another sequences in filters
This commit is contained in:
parent
d37a7f0a0d
commit
b144332287
9 changed files with 53 additions and 23 deletions
|
|
@ -11,6 +11,13 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
|
||||
class TestCommandFilter:
|
||||
def test_convert_to_list(self):
|
||||
cmd = Command(commands="start")
|
||||
assert cmd.commands
|
||||
assert isinstance(cmd.commands, list)
|
||||
assert cmd.commands[0] == "start"
|
||||
assert cmd == Command(commands=["start"])
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_parse_command(self, bot: MockedBot):
|
||||
# TODO: parametrize
|
||||
|
|
|
|||
|
|
@ -25,6 +25,13 @@ class TestContentTypesFilter:
|
|||
filter_ = ContentTypesFilter(content_types=[])
|
||||
assert filter_.content_types == ["text"]
|
||||
|
||||
def test_convert_to_list(self):
|
||||
filter_ = ContentTypesFilter(content_types="text")
|
||||
assert filter_.content_types
|
||||
assert isinstance(filter_.content_types, list)
|
||||
assert filter_.content_types[0] == "text"
|
||||
assert filter_ == ContentTypesFilter(content_types=["text"])
|
||||
|
||||
@pytest.mark.parametrize("values", [["text", "photo"], ["sticker"]])
|
||||
def test_validator_with_values(self, values):
|
||||
filter_ = ContentTypesFilter(content_types=values)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import datetime
|
||||
from itertools import permutations
|
||||
from typing import Type
|
||||
from typing import Sequence, Type
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
|
@ -46,11 +46,11 @@ class TestText:
|
|||
@pytest.mark.parametrize(
|
||||
"argument", ["text", "text_contains", "text_startswith", "text_endswith"]
|
||||
)
|
||||
@pytest.mark.parametrize("input_type", [str, list, tuple, set])
|
||||
@pytest.mark.parametrize("input_type", [str, list, tuple])
|
||||
def test_validator_convert_to_list(self, argument: str, input_type: Type):
|
||||
text = Text(**{argument: input_type("test")})
|
||||
assert hasattr(text, argument)
|
||||
assert isinstance(getattr(text, argument), list)
|
||||
assert isinstance(getattr(text, argument), Sequence)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"argument,ignore_case,input_value,update_type,result",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue