mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 23:27:49 +01:00
Add Filters.entities test.
This commit is contained in:
parent
f7b497c1b4
commit
7ab007d8d4
1 changed files with 23 additions and 1 deletions
|
@ -23,10 +23,11 @@ This module contains a object that represents Tests for MessageHandler.Filters
|
|||
import sys
|
||||
import unittest
|
||||
from datetime import datetime
|
||||
import functools
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
from telegram import Message, User, Chat
|
||||
from telegram import Message, User, Chat, MessageEntity
|
||||
from telegram.ext import Filters
|
||||
from tests.base import BaseTest
|
||||
|
||||
|
@ -150,6 +151,27 @@ class FiltersTest(BaseTest, unittest.TestCase):
|
|||
self.assertTrue(Filters.status_update(self.message))
|
||||
self.message.pinned_message = None
|
||||
|
||||
def test_entities_filter(self):
|
||||
e = functools.partial(MessageEntity, offset=0, length=0)
|
||||
|
||||
self.message.entities = [e(MessageEntity.MENTION)]
|
||||
self.assertTrue(Filters.entities([MessageEntity.MENTION])(self.message))
|
||||
|
||||
self.message.entities = []
|
||||
self.assertFalse(Filters.entities([MessageEntity.MENTION])(self.message))
|
||||
|
||||
self.message.entities = [e(MessageEntity.BOLD)]
|
||||
self.assertFalse(Filters.entities([MessageEntity.MENTION])(self.message))
|
||||
|
||||
self.message.entities = [e(MessageEntity.MENTION)]
|
||||
self.assertTrue(
|
||||
Filters.entities([MessageEntity.MENTION, MessageEntity.BOLD])(self.message))
|
||||
self.message.entities = [e(MessageEntity.BOLD)]
|
||||
self.assertTrue(
|
||||
Filters.entities([MessageEntity.MENTION, MessageEntity.BOLD])(self.message))
|
||||
self.assertFalse(
|
||||
Filters.entities([MessageEntity.MENTION, MessageEntity.TEXT_MENTION])(self.message))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in a new issue