Fixed #1013: Empty mention should be None instead of empty string.

This commit is contained in:
Alex Root Junior 2022-09-27 23:35:36 +03:00
parent 5c218d7983
commit 02357faf03
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
3 changed files with 22 additions and 1 deletions

View file

@ -104,6 +104,23 @@ class TestCommandFilter:
assert "args" in result
assert result["args"] == "42"
async def test_empty_mention_is_none(self, bot: MockedBot):
# Fixed https://github.com/aiogram/aiogram/issues/1013:
# Empty mention should be None instead of empty string.
message = Message(
message_id=0,
text="/test",
chat=Chat(id=42, type="private"),
date=datetime.datetime.now(),
)
command = Command("test")
result = await command(message=message, bot=bot)
assert "command" in result
command_obj: CommandObject = result["command"]
assert command_obj.mention is None
class TestCommandObject:
@pytest.mark.parametrize(