1717# You should have received a copy of the GNU General Public License
1818# along with this program. If not, see [http://www.gnu.org/licenses/].
1919"""This module contains an object that represents Tests for Telegram VideoNote"""
20-
20+ import numbers
2121import sys
2222import unittest
2323import os
@@ -37,7 +37,7 @@ def setUp(self):
3737 self .videonote_file = open ('tests/data/telegram.mp4' , 'rb' )
3838 self .videonote_file_id = 'DQADAQADBwAD5VIIRYemhHpbPmIQAg'
3939 self .duration = 5
40- self .length = 1 # No bloody clue what this does, see note in first test
40+ self .length = 1 # No bloody clue what this does
4141 self .thumb = telegram .PhotoSize .de_json ({
4242 'file_id' : 'AAQBABOMsecvAAQqqoY1Pee_MqcyAAIC' ,
4343 'width' : 51 ,
@@ -56,39 +56,16 @@ def setUp(self):
5656
5757 @flaky (3 , 1 )
5858 @timeout (10 )
59- def test_error_send_videonote_required_args_only (self ):
60- # This is where it gets weird....
61- # According to telegram length is Video width and height.. but how that works with one
62- # parameter I couldn't tell you
63- # It would also seem that it is in fact a required parameter, so the original test below
64- # fails. Therefore I decided I check for the error instead - that way we'll also know
65- # when telegram fixes their shit
66- with self .assertRaisesRegexp (telegram .error .BadRequest , r'Wrong video note length' ):
67- message = self ._bot .sendVideoNote (self ._chat_id , self .videonote_file , timeout = 10 )
68-
69- # videonote = message.videonote
70- #
71- # self.assertTrue(isinstance(videonote.file_id, str))
72- # self.assertNotEqual(videonote.file_id, None)
73- # self.assertEqual(videonote.duration, self.duration)
74- # self.assertEqual(videonote.length, self.length)
75- # self.assertEqual(videonote.thumb, self.thumb)
76- # self.assertEqual(videonote.file_size, self.file_size)
77-
78- @flaky (3 , 1 )
79- @timeout (10 )
80- def test_send_videonote_actual_required_args_only (self ):
81- # See above test... if you pass any number that's > 0 and < some high number, it seems
82- # to work
83- message = self ._bot .sendVideoNote (
84- self ._chat_id , self .videonote_file , length = self .length , timeout = 10 )
59+ def test_send_videonote_required_args_only (self ):
60+ message = self ._bot .sendVideoNote (self ._chat_id , self .videonote_file , timeout = 10 )
8561
8662 videonote = message .video_note
8763
8864 self .assertTrue (isinstance (videonote .file_id , str ))
8965 self .assertNotEqual (videonote .file_id , None )
9066 self .assertEqual (videonote .duration , self .duration )
9167 # self.assertEqual(videonote.length, self.length)
68+ self .assertIsInstance (videonote .length , numbers .Number )
9269 self .assertEqual (videonote .thumb , self .thumb )
9370 self .assertEqual (videonote .file_size , self .file_size )
9471
@@ -107,6 +84,7 @@ def test_send_videonote_all_args(self):
10784 self .assertTrue (isinstance (videonote .file_id , str ))
10885 self .assertNotEqual (videonote .file_id , None )
10986 # self.assertEqual(videonote.length, self.length)
87+ self .assertIsInstance (videonote .length , numbers .Number )
11088 self .assertEqual (videonote .duration , self .duration )
11189 self .assertEqual (videonote .thumb , self .thumb )
11290 self .assertEqual (videonote .file_size , self .file_size )
@@ -125,15 +103,17 @@ def test_send_videonote_resend(self):
125103
126104 self .assertEqual (videonote .file_id , self .videonote_file_id )
127105 # self.assertEqual(videonote.length, self.length)
106+ self .assertIsInstance (videonote .length , numbers .Number )
128107 self .assertEqual (videonote .duration , self .duration )
129108 self .assertEqual (videonote .thumb , self .thumb )
130- self .assertEqual (videonote .file_size , self .file_size )
109+ # Telegram doesn't send file_size for resends?
110+ # self.assertEqual(videonote.file_size, self.file_size)
131111
132112 def test_videonote_de_json (self ):
133113 videonote = telegram .VideoNote .de_json (self .json_dict , self ._bot )
134114
135115 self .assertEqual (videonote .file_id , self .videonote_file_id )
136- # self.assertEqual(videonote.duration, self.duration)
116+ self .assertEqual (videonote .duration , self .duration )
137117 self .assertEqual (videonote .thumb , self .thumb )
138118 self .assertEqual (videonote .length , self .length )
139119 self .assertEqual (videonote .file_size , self .file_size )
0 commit comments