first tries

This commit is contained in:
Eldin 2017-06-20 23:55:35 +02:00
parent eee0f78b15
commit 8a89265c2d
2 changed files with 53 additions and 13 deletions

36
tests/bots.py Normal file
View file

@ -0,0 +1,36 @@
#!/usr/bin/env python
#
# A library that provides a Python interface to the Telegram Bot API
# Copyright (C) 2015-2017
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see [http://www.gnu.org/licenses/].
"""Provide a bot to tests"""
import telegram
bots = [
{
'token': '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0',
'chat_id': '12173560',
'group_id': '-49740850',
'channel_id': '@pythontelegrambottests',
'payment_provider_token': '284685063:TEST:ZGJlMmQxZDI3ZTc3',
'user': telegram.User(133505823, 'PythonTelegramBot', username='PythonTelegramBot')
}
]
def get_bot():
return bots[0]

View file

@ -28,32 +28,36 @@ sys.path.append('.')
import telegram
from tests.base import BaseTest, timeout
from tests.bots import get_bot
class VideoTest(BaseTest, unittest.TestCase):
"""This object represents Tests for Telegram Video."""
@classmethod
def setUpClass(cls):
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_file, timeout=10).video
cls.video_file_id = video.file_id
cls.width = video.width
cls.height = video.height
cls.duration = video.duration
cls.thumb = video.thumb
cls.mime_type = video.mime_type
cls.file_size = video.file_size
def setUp(self):
self.video_file = open('tests/data/telegram.mp4', 'rb')
self.video_file_id = 'BAADAQADXwADHyP1BwJFTcmY2RYCAg'
self.video_file_url = 'https://python-telegram-bot.org/static/website/telegram.mp4'
self.width = 360
self.height = 640
self.duration = 5
self.thumb = telegram.PhotoSize.de_json({
'file_id': 'AAQBABOMsecvAAQqqoY1Pee_MqcyAAIC',
'file_size': 645,
'height': 90,
'width': 51
}, self._bot)
self.thumb_from_url = telegram.PhotoSize.de_json({
'file_id': 'AAQEABPZU2EZAAQ_tPcvcRTF4i1GAQABAg',
'file_size': 645,
'height': 90,
'width': 51
}, self._bot)
self.mime_type = 'video/mp4'
self.file_size = 326534
# caption is part of sendVideo method but not Video object
self.caption = u'VideoTest - Caption'
@ -189,7 +193,7 @@ class VideoTest(BaseTest, unittest.TestCase):
video = message.video
self.assertEqual(video.file_id, self.video_file_id)
self.assertEqual(video.duration, 0)
self.assertEqual(video.duration, 5)
self.assertEqual(video.thumb, None)
self.assertEqual(video.mime_type, 'video/mp4')