Skip to content

Commit 8a89265

Browse files
committed
first tries
1 parent eee0f78 commit 8a89265

2 files changed

Lines changed: 53 additions & 13 deletions

File tree

tests/bots.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
#
3+
# A library that provides a Python interface to the Telegram Bot API
4+
# Copyright (C) 2015-2017
5+
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
"""Provide a bot to tests"""
20+
21+
import telegram
22+
23+
bots = [
24+
{
25+
'token': '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0',
26+
'chat_id': '12173560',
27+
'group_id': '-49740850',
28+
'channel_id': '@pythontelegrambottests',
29+
'payment_provider_token': '284685063:TEST:ZGJlMmQxZDI3ZTc3',
30+
'user': telegram.User(133505823, 'PythonTelegramBot', username='PythonTelegramBot')
31+
}
32+
]
33+
34+
35+
def get_bot():
36+
return bots[0]

tests/test_video.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,36 @@
2828

2929
import telegram
3030
from tests.base import BaseTest, timeout
31+
from tests.bots import get_bot
3132

3233

3334
class VideoTest(BaseTest, unittest.TestCase):
3435
"""This object represents Tests for Telegram Video."""
36+
@classmethod
37+
def setUpClass(cls):
38+
bot_info = get_bot()
39+
cls._chat_id = bot_info['chat_id']
40+
cls._bot = telegram.Bot(bot_info['token'])
41+
video_file = open('tests/data/telegram.mp4', 'rb')
42+
video = cls._bot.send_video(cls._chat_id, video_file, timeout=10).video
43+
cls.video_file_id = video.file_id
44+
cls.width = video.width
45+
cls.height = video.height
46+
cls.duration = video.duration
47+
cls.thumb = video.thumb
48+
cls.mime_type = video.mime_type
49+
cls.file_size = video.file_size
50+
3551

3652
def setUp(self):
3753
self.video_file = open('tests/data/telegram.mp4', 'rb')
38-
self.video_file_id = 'BAADAQADXwADHyP1BwJFTcmY2RYCAg'
3954
self.video_file_url = 'https://python-telegram-bot.org/static/website/telegram.mp4'
40-
self.width = 360
41-
self.height = 640
42-
self.duration = 5
43-
self.thumb = telegram.PhotoSize.de_json({
44-
'file_id': 'AAQBABOMsecvAAQqqoY1Pee_MqcyAAIC',
45-
'file_size': 645,
46-
'height': 90,
47-
'width': 51
48-
}, self._bot)
4955
self.thumb_from_url = telegram.PhotoSize.de_json({
5056
'file_id': 'AAQEABPZU2EZAAQ_tPcvcRTF4i1GAQABAg',
5157
'file_size': 645,
5258
'height': 90,
5359
'width': 51
5460
}, self._bot)
55-
self.mime_type = 'video/mp4'
56-
self.file_size = 326534
5761

5862
# caption is part of sendVideo method but not Video object
5963
self.caption = u'VideoTest - Caption'
@@ -189,7 +193,7 @@ def test_send_video_resend(self):
189193
video = message.video
190194

191195
self.assertEqual(video.file_id, self.video_file_id)
192-
self.assertEqual(video.duration, 0)
196+
self.assertEqual(video.duration, 5)
193197
self.assertEqual(video.thumb, None)
194198
self.assertEqual(video.mime_type, 'video/mp4')
195199

0 commit comments

Comments
 (0)