Reflecting tests for Filters change

This commit is contained in:
Leandro Toledo 2016-05-27 21:14:55 -03:00
parent 22e9326610
commit 80fbe98b44

View file

@ -26,7 +26,7 @@ from datetime import datetime
sys.path.append('.')
from telegram import Update, Message, User, Chat
from telegram import Message, User, Chat
from telegram.ext import Filters
from tests.base import BaseTest
@ -36,119 +36,118 @@ class FiltersTest(BaseTest, unittest.TestCase):
def setUp(self):
self.message = Message(0, User(0, "Testuser"), datetime.now(), Chat(0, 'private'))
self.update = Update(0, message=self.message)
def test_filters_text(self):
self.message.text = 'test'
self.assertTrue(Filters.text(self.update))
self.assertTrue(Filters.text(self.message))
self.message.text = '/test'
self.assertFalse(Filters.text(self.update))
self.assertFalse(Filters.text(self.message))
def test_filters_command(self):
self.message.text = 'test'
self.assertFalse(Filters.command(self.update))
self.assertFalse(Filters.command(self.message))
self.message.text = '/test'
self.assertTrue(Filters.command(self.update))
self.assertTrue(Filters.command(self.message))
def test_filters_audio(self):
self.message.audio = 'test'
self.assertTrue(Filters.audio(self.update))
self.assertTrue(Filters.audio(self.message))
self.message.audio = None
self.assertFalse(Filters.audio(self.update))
self.assertFalse(Filters.audio(self.message))
def test_filters_document(self):
self.message.document = 'test'
self.assertTrue(Filters.document(self.update))
self.assertTrue(Filters.document(self.message))
self.message.document = None
self.assertFalse(Filters.document(self.update))
self.assertFalse(Filters.document(self.message))
def test_filters_photo(self):
self.message.photo = 'test'
self.assertTrue(Filters.photo(self.update))
self.assertTrue(Filters.photo(self.message))
self.message.photo = None
self.assertFalse(Filters.photo(self.update))
self.assertFalse(Filters.photo(self.message))
def test_filters_sticker(self):
self.message.sticker = 'test'
self.assertTrue(Filters.sticker(self.update))
self.assertTrue(Filters.sticker(self.message))
self.message.sticker = None
self.assertFalse(Filters.sticker(self.update))
self.assertFalse(Filters.sticker(self.message))
def test_filters_video(self):
self.message.video = 'test'
self.assertTrue(Filters.video(self.update))
self.assertTrue(Filters.video(self.message))
self.message.video = None
self.assertFalse(Filters.video(self.update))
self.assertFalse(Filters.video(self.message))
def test_filters_voice(self):
self.message.voice = 'test'
self.assertTrue(Filters.voice(self.update))
self.assertTrue(Filters.voice(self.message))
self.message.voice = None
self.assertFalse(Filters.voice(self.update))
self.assertFalse(Filters.voice(self.message))
def test_filters_contact(self):
self.message.contact = 'test'
self.assertTrue(Filters.contact(self.update))
self.assertTrue(Filters.contact(self.message))
self.message.contact = None
self.assertFalse(Filters.contact(self.update))
self.assertFalse(Filters.contact(self.message))
def test_filters_location(self):
self.message.location = 'test'
self.assertTrue(Filters.location(self.update))
self.assertTrue(Filters.location(self.message))
self.message.location = None
self.assertFalse(Filters.location(self.update))
self.assertFalse(Filters.location(self.message))
def test_filters_venue(self):
self.message.venue = 'test'
self.assertTrue(Filters.venue(self.update))
self.assertTrue(Filters.venue(self.message))
self.message.venue = None
self.assertFalse(Filters.venue(self.update))
self.assertFalse(Filters.venue(self.message))
def test_filters_status_update(self):
self.assertFalse(Filters.status_update(self.update))
self.assertFalse(Filters.status_update(self.message))
self.message.new_chat_member = 'test'
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.new_chat_member = None
self.message.left_chat_member = 'test'
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.left_chat_member = None
self.message.new_chat_title = 'test'
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.new_chat_title = ''
self.message.new_chat_photo = 'test'
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.new_chat_photo = None
self.message.delete_chat_photo = True
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.delete_chat_photo = False
self.message.group_chat_created = True
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.group_chat_created = False
self.message.supergroup_chat_created = True
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.supergroup_chat_created = False
self.message.migrate_to_chat_id = 100
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.migrate_to_chat_id = 0
self.message.migrate_from_chat_id = 100
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.migrate_from_chat_id = 0
self.message.channel_chat_created = True
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.channel_chat_created = False
self.message.pinned_message = 'test'
self.assertTrue(Filters.status_update(self.update))
self.assertTrue(Filters.status_update(self.message))
self.message.pinned_message = None