@@ -33,44 +33,40 @@ class VideoTest(BaseTest, unittest.TestCase):
3333
3434 @classmethod
3535 def setUpClass (cls ):
36+ cls .caption = u'VideoTest - Caption'
37+ cls .video_file_url = 'https://python-telegram-bot.org/static/website/telegram.mp4'
38+
3639 bot_info = get_bot ()
3740 cls ._chat_id = bot_info ['chat_id' ]
3841 cls ._bot = telegram .Bot (bot_info ['token' ])
42+
3943 video_file = open ('tests/data/telegram.mp4' , 'rb' )
4044 video = cls ._bot .send_video (cls ._chat_id , video = video_file , timeout = 10 ).video
41- cls .video_file_id = video .file_id
42- cls .width = video .width
43- cls .height = video .height
44- cls .duration = video .duration
45- cls .thumb = video .thumb
46- cls .mime_type = video .mime_type
47- cls .file_size = video .file_size
48- cls .video_file_url = 'https://python-telegram-bot.org/static/website/telegram.mp4'
49- cls .caption = u'VideoTest - Caption'
50- cls .thumb_from_url = telegram .PhotoSize .de_json ({
51- 'file_id' : 'AAQEABPZU2EZAAQ_tPcvcRTF4i1GAQABAg' ,
52- 'file_size' : 645 ,
53- 'height' : 90 ,
54- 'width' : 51
55- }, cls ._bot )
45+ cls .video = video
46+
47+ # Make sure file has been uploaded.
48+ cls .assertIsInstance (cls (), cls .video , telegram .Video )
49+ cls .assertIsInstance (cls (), cls .video .file_id , str )
50+ cls .assertNotEqual (cls (), cls .video .file_id , '' )
5651
5752 def setUp (self ):
5853 self .video_file = open ('tests/data/telegram.mp4' , 'rb' )
5954 self .json_dict = {
60- 'file_id' : self .video_file_id ,
61- 'width' : self .width ,
62- 'height' : self .height ,
63- 'duration' : self .duration ,
64- 'thumb' : self .thumb .to_dict (),
65- 'mime_type' : self .mime_type ,
66- 'file_size' : self .file_size
55+ 'file_id' : self .video . file_id ,
56+ 'width' : self .video . width ,
57+ 'height' : self .video . height ,
58+ 'duration' : self .video . duration ,
59+ 'thumb' : self .video . thumb .to_dict (),
60+ 'mime_type' : self .video . mime_type ,
61+ 'file_size' : self .video . file_size
6762 }
6863
69- @flaky (3 , 1 )
70- @timeout (10 )
71- def test_send_video_required_args_only (self ):
72- # obsolete since it's done in the setUpClass
73- self .assertEqual (True , True )
64+ def test_expected_values (self ):
65+ self .assertEqual (self .video .width , 360 )
66+ self .assertEqual (self .video .height , 640 )
67+ self .assertEqual (self .video .duration , 5 )
68+ self .assertEqual (self .video .file_size , 326534 )
69+ self .assertEqual (self .video .mime_type , 'video/mp4' )
7470
7571 @flaky (3 , 1 )
7672 @timeout (10 )
@@ -79,50 +75,20 @@ def test_send_video_all_args(self):
7975 self ._chat_id ,
8076 self .video_file ,
8177 timeout = 10 ,
82- duration = self .duration ,
78+ duration = self .video . duration ,
8379 caption = self .caption ,
8480 disable_notification = False )
8581
8682 video = message .video
8783
8884 self .assertTrue (isinstance (video .file_id , str ))
8985 self .assertNotEqual (video .file_id , None )
90- self .assertEqual (video .width , self .width )
91- self .assertEqual (video .height , self .height )
92- self .assertEqual (video .duration , self .duration )
93- self .assertEqual (video .thumb , self .thumb )
94- self .assertEqual (video .mime_type , self .mime_type )
95- self .assertEqual (video .file_size , self .file_size )
96-
97- self .assertEqual (message .caption , self .caption )
98-
99- @flaky (3 , 1 )
100- @timeout (10 )
101- def test_send_video_mp4_file (self ):
102- # identical to all_args so obsolete
103- self .assertEqual (True , True )
104-
105- @flaky (3 , 1 )
106- @timeout (10 )
107- def test_send_video_mp4_file_with_custom_filename (self ):
108- message = self ._bot .sendVideo (
109- chat_id = self ._chat_id ,
110- video = self .video_file ,
111- timeout = 10 ,
112- duration = self .duration ,
113- caption = self .caption ,
114- filename = 'telegram_custom.mp4' )
115-
116- video = message .video
117-
118- self .assertTrue (isinstance (video .file_id , str ))
119- self .assertNotEqual (video .file_id , '' )
120- self .assertEqual (video .width , self .width )
121- self .assertEqual (video .height , self .height )
122- self .assertEqual (video .duration , self .duration )
123- self .assertEqual (video .thumb , self .thumb )
124- self .assertEqual (video .mime_type , self .mime_type )
125- self .assertEqual (video .file_size , self .file_size )
86+ self .assertEqual (video .width , self .video .width )
87+ self .assertEqual (video .height , self .video .height )
88+ self .assertEqual (video .duration , self .video .duration )
89+ self .assertEqual (video .thumb , self .video .thumb )
90+ self .assertEqual (video .mime_type , self .video .mime_type )
91+ self .assertEqual (video .file_size , self .video .file_size )
12692
12793 self .assertEqual (message .caption , self .caption )
12894
@@ -139,43 +105,45 @@ def test_send_video_mp4_file_url(self):
139105
140106 self .assertTrue (isinstance (video .file_id , str ))
141107 self .assertNotEqual (video .file_id , None )
142- self .assertEqual (video .height , self .height )
143- self .assertEqual (video .duration , self .duration )
144- self .assertEqual (video .thumb , self .thumb_from_url )
145- self .assertEqual (video .mime_type , self .mime_type )
146- self .assertEqual (video .file_size , self .file_size )
147-
108+ self .assertEqual (video .height , self .video .height )
109+ self .assertEqual (video .duration , self .video .duration )
110+ self .assertEqual (video .mime_type , self .video .mime_type )
111+ self .assertEqual (video .file_size , self .video .file_size )
148112 self .assertEqual (message .caption , self .caption )
113+ thumb = video .thumb
114+ self .assertEqual (thumb .height , self .video .thumb .height )
115+ self .assertEqual (thumb .width , self .video .thumb .width )
116+ self .assertEqual (thumb .file_size , self .video .thumb .file_size )
149117
150118 @flaky (3 , 1 )
151119 @timeout (10 )
152120 def test_send_video_resend (self ):
153121 message = self ._bot .sendVideo (
154122 chat_id = self ._chat_id ,
155- video = self .video_file_id ,
123+ video = self .video . file_id ,
156124 timeout = 10 ,
157- duration = self .duration ,
125+ duration = self .video . duration ,
158126 caption = self .caption )
159127
160128 video = message .video
161129
162- self .assertEqual (video .file_id , self .video_file_id )
163- self .assertEqual (video .duration , self .duration )
164- self .assertEqual (video .thumb , self .thumb )
165- self .assertEqual (video .mime_type , self .mime_type )
130+ self .assertEqual (video .file_id , self .video . file_id )
131+ self .assertEqual (video .duration , self .video . duration )
132+ self .assertEqual (video .thumb , self .video . thumb )
133+ self .assertEqual (video .mime_type , self .video . mime_type )
166134
167135 self .assertEqual (message .caption , self .caption )
168136
169137 def test_video_de_json (self ):
170138 video = telegram .Video .de_json (self .json_dict , self ._bot )
171139
172- self .assertEqual (video .file_id , self .video_file_id )
173- self .assertEqual (video .width , self .width )
174- self .assertEqual (video .height , self .height )
175- self .assertEqual (video .duration , self .duration )
176- self .assertEqual (video .thumb , self .thumb )
177- self .assertEqual (video .mime_type , self .mime_type )
178- self .assertEqual (video .file_size , self .file_size )
140+ self .assertEqual (video .file_id , self .video . file_id )
141+ self .assertEqual (video .width , self .video . width )
142+ self .assertEqual (video .height , self .video . height )
143+ self .assertEqual (video .duration , self .video . duration )
144+ self .assertEqual (video .thumb , self .video . thumb )
145+ self .assertEqual (video .mime_type , self .video . mime_type )
146+ self .assertEqual (video .file_size , self .video . file_size )
179147
180148 def test_video_to_json (self ):
181149 video = telegram .Video .de_json (self .json_dict , self ._bot )
@@ -186,12 +154,12 @@ def test_video_to_dict(self):
186154 video = telegram .Video .de_json (self .json_dict , self ._bot )
187155
188156 self .assertTrue (self .is_dict (video .to_dict ()))
189- self .assertEqual (video ['file_id' ], self .video_file_id )
190- self .assertEqual (video ['width' ], self .width )
191- self .assertEqual (video ['height' ], self .height )
192- self .assertEqual (video ['duration' ], self .duration )
193- self .assertEqual (video ['mime_type' ], self .mime_type )
194- self .assertEqual (video ['file_size' ], self .file_size )
157+ self .assertEqual (video ['file_id' ], self .video . file_id )
158+ self .assertEqual (video ['width' ], self .video . width )
159+ self .assertEqual (video ['height' ], self .video . height )
160+ self .assertEqual (video ['duration' ], self .video . duration )
161+ self .assertEqual (video ['mime_type' ], self .video . mime_type )
162+ self .assertEqual (video ['file_size' ], self .video . file_size )
195163
196164 @flaky (3 , 1 )
197165 @timeout (10 )
@@ -231,11 +199,11 @@ def test_reply_video(self):
231199 self .assertNotEqual (message .video .file_id , None )
232200
233201 def test_equality (self ):
234- a = telegram .Video (self .video_file_id , self .width , self .height , self .duration )
235- b = telegram .Video (self .video_file_id , self .width , self .height , self .duration )
236- c = telegram .Video (self .video_file_id , 0 , 0 , 0 )
237- d = telegram .Video ("" , self .width , self .height , self .duration )
238- e = telegram .Voice (self .video_file_id , self .duration )
202+ a = telegram .Video (self .video . file_id , self .video . width , self .video . height , self . video .duration )
203+ b = telegram .Video (self .video . file_id , self .video . width , self .video . height , self . video .duration )
204+ c = telegram .Video (self .video . file_id , 0 , 0 , 0 )
205+ d = telegram .Video ("" , self .video . width , self .video . height , self . video .duration )
206+ e = telegram .Voice (self .video . file_id , self . video .duration )
239207
240208 self .assertEqual (a , b )
241209 self .assertEqual (hash (a ), hash (b ))
0 commit comments