mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Update tests
This commit is contained in:
parent
4dfd86fd7d
commit
237c98636a
14 changed files with 440 additions and 396 deletions
|
|
@ -37,6 +37,8 @@ class TestBaseFilter:
|
|||
my_filter = MyFilter()
|
||||
my_inverted_filter = ~my_filter
|
||||
|
||||
assert str(my_inverted_filter) == f"~{str(my_filter)}"
|
||||
|
||||
assert isinstance(my_inverted_filter, _InvertFilter)
|
||||
|
||||
with patch(
|
||||
|
|
|
|||
|
|
@ -179,3 +179,7 @@ class TestCallbackDataFilter:
|
|||
async def test_invalid_call(self):
|
||||
filter_object = MyCallback.filter(F.test)
|
||||
assert not await filter_object(User(id=42, is_bot=False, first_name="test"))
|
||||
|
||||
def test_str(self):
|
||||
filter_object = MyCallback.filter(F.test)
|
||||
assert str(filter_object).startswith("CallbackQueryFilter(callback_data=")
|
||||
|
|
|
|||
|
|
@ -343,3 +343,7 @@ class TestChatMemberUpdatedStatusFilter:
|
|||
)
|
||||
|
||||
assert await updated_filter(event) is result
|
||||
|
||||
def test_str(self):
|
||||
updated_filter = ChatMemberUpdatedFilter(member_status_changed=JOIN_TRANSITION)
|
||||
assert str(updated_filter).startswith("ChatMemberUpdatedFilter(member_status_changed=")
|
||||
|
|
|
|||
|
|
@ -151,3 +151,7 @@ class TestCommandObject:
|
|||
|
||||
cmd.update_handler_flags(flags)
|
||||
assert len(flags["commands"]) == 2
|
||||
|
||||
def test_str(self):
|
||||
cmd = Command(commands=["start"])
|
||||
assert str(cmd) == "Command('start', prefix='/', ignore_case=False, ignore_mention=False)"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,10 @@ class TestExceptionMessageFilter:
|
|||
assert isinstance(result, dict)
|
||||
assert "match_exception" in result
|
||||
|
||||
async def test_str(self):
|
||||
obj = ExceptionMessageFilter(pattern="KABOOM")
|
||||
assert str(obj) == "ExceptionMessageFilter(pattern=re.compile('KABOOM'))"
|
||||
|
||||
|
||||
class MyException(Exception):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -28,3 +28,7 @@ class TestMagicDataFilter:
|
|||
assert called
|
||||
assert isinstance(result, dict)
|
||||
assert result["test"]
|
||||
|
||||
def test_str(self):
|
||||
f = MagicData(magic_data=F.event.text == "test")
|
||||
assert str(f).startswith("MagicData(magic_data=")
|
||||
|
|
|
|||
|
|
@ -68,3 +68,7 @@ class TestStateFilter:
|
|||
|
||||
states = {SG.state: "OK"}
|
||||
assert states.get(copy(SG.state)) == "OK"
|
||||
|
||||
def test_str(self):
|
||||
f = StateFilter("test")
|
||||
assert str(f) == "StateFilter('test')"
|
||||
|
|
|
|||
|
|
@ -233,3 +233,7 @@ class TestText:
|
|||
text = Text(**{argument: input_value}, ignore_case=ignore_case)
|
||||
test = await text(update_type)
|
||||
assert test is result
|
||||
|
||||
def test_str(self):
|
||||
text = Text("test")
|
||||
assert str(text) == "Text(text=['test'], ignore_case=False)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue