def setUpClass(cls): bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) cls._group_id = bot_info['group_id'] cls._channel_id = bot_info['channel_id'] cls._payment_provider_token = bot_info['payment_provider_token']
def setUpClass(cls): cls.emoji = telegram.Emoji.FLEXED_BICEPS # cls.sticker_file_url = "https://python-telegram-bot.org/static/testfiles/telegram.webp" # Serving sticker from gh since our server sends wrong content_type cls.sticker_file_url = "https://github.com/python-telegram-bot/python-telegram-bot/blob/master/tests/data/telegram.webp?raw=true" # noqa bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) sticker_file = open('tests/data/telegram.webp', 'rb') sticker = cls._bot.send_sticker(cls._chat_id, sticker=sticker_file, timeout=10).sticker cls.sticker = sticker cls.thumb = sticker.thumb # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.sticker, telegram.Sticker) assert isinstance(cls.sticker.file_id, str) assert cls.sticker.file_id is not '' assert isinstance(cls.thumb, telegram.PhotoSize) assert isinstance(cls.thumb.file_id, str) assert cls.thumb.file_id is not ''
def make_message(text, **kwargs): """ Testing utility factory to create a fake ``telegram.Message`` with reasonable defaults for mimicking a real message. :param text: (str) message text :return: a (fake) ``telegram.Message`` """ return Message(message_id=1, from_user=kwargs.pop('user', User(id=1, first_name='first_name', is_bot=False,username='******')), date=kwargs.pop('date', DATE), chat=kwargs.pop('chat', Chat(id=1, type='')), text=text, bot=kwargs.pop('bot', make_bot(get_bot())), **kwargs)
def setUpClass(cls): bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) videonote_file = open('tests/data/telegram2.mp4', 'rb') video_note = cls._bot.send_video_note(cls._chat_id, video_note=videonote_file, timeout=10).video_note cls.videonote = video_note # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.videonote, telegram.VideoNote) assert isinstance(cls.videonote.file_id, str) assert cls.videonote.file_id is not ''
def setUpClass(cls): cls.voice_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.ogg' cls.caption = u"Test voice" voice_file = open('tests/data/telegram.ogg', 'rb') bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) voice = cls._bot.send_voice(cls._chat_id, voice=voice_file).voice cls.voice = voice # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.voice, telegram.Voice) assert isinstance(cls.voice.file_id, str) assert cls.voice.file_id is not ''
def setUpClass(cls): cls.voice_file_url = 'https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/tests/data/telegram.ogg' cls.caption = u"Test voice" voice_file = open('tests/data/telegram.ogg', 'rb') bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) voice = cls._bot.send_voice(cls._chat_id, voice=voice_file).voice cls.voice = voice # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.voice, telegram.Voice) assert isinstance(cls.voice.file_id, str) assert cls.voice.file_id is not ''
def setUpClass(cls): cls.caption = u'VideoTest - Caption' cls.video_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.mp4' bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) video_file = open('tests/data/telegram.mp4', 'rb') video = cls._bot.send_video(cls._chat_id, video=video_file, timeout=10).video cls.video = video # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.video, telegram.Video) assert isinstance(cls.video.file_id, str) assert cls.video.file_id is not ''
def setUpClass(cls): cls.caption = u'DocumentTest - Caption' cls.document_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.gif' bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) document_file = open('tests/data/telegram.png', 'rb') document = cls._bot.send_document(cls._chat_id, document=document_file, timeout=10).document cls.document = document # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.document, telegram.Document) assert isinstance(cls.document.file_id, str) assert cls.document.file_id is not ''
def setUpClass(cls): cls.caption = u'VideoTest - Caption' cls.video_file_url = 'https://python-telegram-bot.org/static/website/telegram.mp4' bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) video_file = open('tests/data/telegram.mp4', 'rb') video = cls._bot.send_video(cls._chat_id, video=video_file, timeout=10).video cls.video = video # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.video, telegram.Video) assert isinstance(cls.video.file_id, str) assert cls.video.file_id is not ''
def make_message(text, **kwargs): """ Testing utility factory to create a fake ``telegram.Message`` with reasonable defaults for mimicking a real message. :param text: (str) message text :return: a (fake) ``telegram.Message`` """ bot = kwargs.pop("bot", None) if bot is None: bot = make_bot(get_bot()) return Message( message_id=1, from_user=kwargs.pop("user", User(id=1, first_name="", is_bot=False)), date=kwargs.pop("date", DATE), chat=kwargs.pop("chat", Chat(id=1, type="")), text=text, bot=bot, **kwargs, )
def setUpClass(cls): cls.caption = "Test audio" cls.performer = 'Leandro Toledo' cls.title = 'Teste' cls.audio_file_url = 'https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/tests/data/telegram.mp3' bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) audio_file = open('tests/data/telegram.mp3', 'rb') audio = cls._bot.send_audio(cls._chat_id, audio=audio_file, timeout=10).audio cls.audio = audio # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.audio, telegram.Audio) assert isinstance(cls.audio.file_id, str) assert cls.audio.file_id is not ''
def setUpClass(cls): cls.caption = u'DocumentTest - Caption' cls.document_file_url = 'https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/tests/data/telegram.gif' bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) document_file = open('tests/data/telegram.png', 'rb') document = cls._bot.send_document(cls._chat_id, document=document_file, timeout=10).document cls.document = document # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.document, telegram.Document) assert isinstance(cls.document.file_id, str) assert cls.document.file_id is not ''
def setUpClass(cls): cls.caption = u'PhotoTest - Caption' cls.photo_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.jpg' bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) photo_file = open('tests/data/telegram.jpg', 'rb') photo = cls._bot.send_photo(cls._chat_id, photo=photo_file, timeout=10).photo cls.thumb, cls.photo = photo # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.photo, telegram.PhotoSize) assert isinstance(cls.thumb, telegram.PhotoSize) assert isinstance(cls.photo.file_id, str) assert isinstance(cls.thumb.file_id, str) assert cls.photo.file_id is not '' assert cls.thumb.file_id is not ''
def setUpClass(cls): cls.caption = u'PhotoTest - Caption' cls.photo_file_url = 'https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/tests/data/telegram.jpg' bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) photo_file = open('tests/data/telegram.jpg', 'rb') photo = cls._bot.send_photo(cls._chat_id, photo=photo_file, timeout=10).photo cls.thumb, cls.photo = photo # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.photo, telegram.PhotoSize) assert isinstance(cls.thumb, telegram.PhotoSize) assert isinstance(cls.photo.file_id, str) assert isinstance(cls.thumb.file_id, str) assert cls.photo.file_id is not '' assert cls.thumb.file_id is not ''
def setUpClass(cls): cls.caption = "Test audio" cls.performer = 'Leandro Toledo' cls.title = 'Teste' # cls.audio_file_url = 'https://python-telegram-bot.org/static/testfiles/telegram.mp3' # Shortened link, the above one is cached with the wrong duration. cls.audio_file_url = "https://goo.gl/3En24v" bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) audio_file = open('tests/data/telegram.mp3', 'rb') audio = cls._bot.send_audio(cls._chat_id, audio=audio_file, timeout=10).audio cls.audio = audio # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.audio, telegram.Audio) assert isinstance(cls.audio.file_id, str) assert cls.audio.file_id is not ''
def setUpClass(cls): cls.emoji = telegram.Emoji.FLEXED_BICEPS cls.sticker_file_url = "https://raw.githubusercontent.com/python-telegram-bot/python-telegram-bot/master/tests/data/telegram.webp" # noqa bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) sticker_file = open('tests/data/telegram.webp', 'rb') sticker = cls._bot.send_sticker(cls._chat_id, sticker=sticker_file, timeout=10).sticker cls.sticker = sticker cls.thumb = sticker.thumb # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.sticker, telegram.Sticker) assert isinstance(cls.sticker.file_id, str) assert cls.sticker.file_id is not '' assert isinstance(cls.thumb, telegram.PhotoSize) assert isinstance(cls.thumb.file_id, str) assert cls.thumb.file_id is not ''
def setUpClass(cls): cls.emoji = '💪' # cls.sticker_file_url = "https://python-telegram-bot.org/static/testfiles/telegram.webp" # Serving sticker from gh since our server sends wrong content_type cls.sticker_file_url = "https://github.com/python-telegram-bot/python-telegram-bot/blob/master/tests/data/telegram.webp?raw=true" # noqa bot_info = get_bot() cls._chat_id = bot_info['chat_id'] cls._bot = telegram.Bot(bot_info['token']) sticker_file = open('tests/data/telegram.webp', 'rb') sticker = cls._bot.send_sticker(cls._chat_id, sticker=sticker_file, timeout=10).sticker cls.sticker = sticker cls.thumb = sticker.thumb # Make sure file has been uploaded. # Simple assertions PY2 Only assert isinstance(cls.sticker, telegram.Sticker) assert isinstance(cls.sticker.file_id, str) assert cls.sticker.file_id is not '' assert isinstance(cls.thumb, telegram.PhotoSize) assert isinstance(cls.thumb.file_id, str) assert cls.thumb.file_id is not ''
def bot_info(): return get_bot()