fix: bug IDFilter checking message from channel

This commit is contained in:
Egor 2020-07-03 12:09:45 +05:00
parent 21b4b64db1
commit d5f97e9ab4
3 changed files with 30 additions and 3 deletions

View file

@ -6,10 +6,10 @@ import pytest
from aiogram.dispatcher.filters.builtin import (
Text,
extract_chat_ids,
ChatIDArgumentType, ForwardedMessageFilter,
ChatIDArgumentType, ForwardedMessageFilter, IDFilter,
)
from aiogram.types import Message
from tests.types.dataset import MESSAGE
from tests.types.dataset import MESSAGE, MESSAGE_FROM_CHANNEL
class TestText:
@ -94,3 +94,14 @@ class TestForwardedMessageFilter:
assert await filter.check(not_forwarded_message)
assert not await filter.check(forwarded_message)
class TestIDFilter:
@pytest.mark.asyncio
async def test_chat_id_for_channels(self):
message_from_channel = Message(**MESSAGE_FROM_CHANNEL)
filter = IDFilter(chat_id=message_from_channel.chat.id)
assert await filter.check(message_from_channel)

View file

@ -409,6 +409,20 @@ MESSAGE_WITH_VOICE = {
"voice": VOICE,
}
CHANNEL = {
"type": "channel",
"username": "best_channel_ever",
"id": -1001065170817,
}
MESSAGE_FROM_CHANNEL = {
"message_id": 123432,
"from": None,
"chat": CHANNEL,
"date": 1508768405,
"text": "Hi, world!",
}
PRE_CHECKOUT_QUERY = {
"id": "262181558630368727",
"from": USER,