|
28 | 28 |
|
29 | 29 | import telegram |
30 | 30 | from tests.base import BaseTest, timeout |
| 31 | +from tests.bots import get_bot |
31 | 32 |
|
32 | 33 |
|
33 | 34 | class VideoTest(BaseTest, unittest.TestCase): |
34 | 35 | """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 | + |
35 | 51 |
|
36 | 52 | def setUp(self): |
37 | 53 | self.video_file = open('tests/data/telegram.mp4', 'rb') |
38 | | - self.video_file_id = 'BAADAQADXwADHyP1BwJFTcmY2RYCAg' |
39 | 54 | 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) |
49 | 55 | self.thumb_from_url = telegram.PhotoSize.de_json({ |
50 | 56 | 'file_id': 'AAQEABPZU2EZAAQ_tPcvcRTF4i1GAQABAg', |
51 | 57 | 'file_size': 645, |
52 | 58 | 'height': 90, |
53 | 59 | 'width': 51 |
54 | 60 | }, self._bot) |
55 | | - self.mime_type = 'video/mp4' |
56 | | - self.file_size = 326534 |
57 | 61 |
|
58 | 62 | # caption is part of sendVideo method but not Video object |
59 | 63 | self.caption = u'VideoTest - Caption' |
@@ -189,7 +193,7 @@ def test_send_video_resend(self): |
189 | 193 | video = message.video |
190 | 194 |
|
191 | 195 | self.assertEqual(video.file_id, self.video_file_id) |
192 | | - self.assertEqual(video.duration, 0) |
| 196 | + self.assertEqual(video.duration, 5) |
193 | 197 | self.assertEqual(video.thumb, None) |
194 | 198 | self.assertEqual(video.mime_type, 'video/mp4') |
195 | 199 |
|
|
0 commit comments