X Tutup
Skip to content

Commit 20b856a

Browse files
committed
Update test to support UTF8 text messages
1 parent 649fbc4 commit 20b856a

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

tests/test_bot.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ class BotTest(unittest.TestCase):
1111
def setUp(self):
1212
bot = telegram.Bot(token=os.environ.get('TOKEN'))
1313
self._bot = bot
14-
print 'Testing the Bot API class'
14+
print('Testing the Bot API class')
1515

1616
def testGetMe(self):
1717
'''Test the telegram.Bot getMe method'''
18-
print 'Testing getMe'
18+
print('Testing getMe')
1919
user = self._bot.getMe()
2020
self.assertEqual(120405045, user.id)
2121
self.assertEqual('Toledo\'s Palace Bot', user.first_name)
@@ -24,92 +24,92 @@ def testGetMe(self):
2424

2525
def testSendMessage(self):
2626
'''Test the telegram.Bot sendMessage method'''
27-
print 'Testing sendMessage'
27+
print('Testing sendMessage')
2828
message = self._bot.sendMessage(chat_id=12173560,
29-
text=u'Моё судно на воздушной подушке полно угрей'.encode('utf8'))
30-
self.assertEqual(u'Моё судно на воздушной подушке полно угрей', message.text)
29+
text='Моё судно на воздушной подушке полно угрей')
30+
self.assertEqual('Моё судно на воздушной подушке полно угрей', message.text)
3131

3232
def testGetUpdates(self):
3333
'''Test the telegram.Bot getUpdates method'''
34-
print 'Testing getUpdates'
34+
print('Testing getUpdates')
3535
updates = self._bot.getUpdates()
36-
self.assertEqual(129566590, updates[0].update_id)
36+
self.assertEqual(129566611, updates[0].update_id)
3737

3838
def testForwardMessage(self):
3939
'''Test the telegram.Bot forwardMessage method'''
40-
print 'Testing forwardMessage'
40+
print('Testing forwardMessage')
4141
message = self._bot.forwardMessage(chat_id=12173560,
4242
from_chat_id=12173560,
4343
message_id=138)
44-
self.assertEqual(u'Oi', message.text)
45-
self.assertEqual(u'leandrotoledo', message.forward_from.username)
44+
self.assertEqual('Oi', message.text)
45+
self.assertEqual('leandrotoledo', message.forward_from.username)
4646

4747
def testSendPhoto(self):
4848
'''Test the telegram.Bot sendPhoto method'''
49-
print 'Testing sendPhoto - File'
49+
print('Testing sendPhoto - File')
5050
message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'),
5151
chat_id=12173560)
5252
self.assertEqual(1451, message.photo[0].file_size)
5353

5454
def testResendPhoto(self):
5555
'''Test the telegram.Bot sendPhoto method'''
56-
print 'Testing sendPhoto - Resend'
56+
print('Testing sendPhoto - Resend')
5757
message = self._bot.sendPhoto(photo=str('AgADAQADr6cxGzU8LQe6q0dMJD2rHYkP2ykABFymiQqJgjxRGGMAAgI'),
5858
chat_id=12173560)
59-
self.assertEqual(u'AgADAQADr6cxGzU8LQe6q0dMJD2rHYkP2ykABFymiQqJgjxRGGMAAgI', message.photo[0].file_id)
59+
self.assertEqual('AgADAQADr6cxGzU8LQe6q0dMJD2rHYkP2ykABFymiQqJgjxRGGMAAgI', message.photo[0].file_id)
6060

6161
def testSendAudio(self):
6262
'''Test the telegram.Bot sendAudio method'''
63-
print 'Testing sendAudio - File'
63+
print('Testing sendAudio - File')
6464
message = self._bot.sendAudio(audio=open('tests/telegram.ogg', 'rb'),
6565
chat_id=12173560)
6666
self.assertEqual(9199, message.audio.file_size)
6767

6868
def testResendAudio(self):
6969
'''Test the telegram.Bot sendAudio method'''
70-
print 'Testing sendAudio - Resend'
70+
print('Testing sendAudio - Resend')
7171
message = self._bot.sendAudio(audio=str('AwADAQADIQEAAvjAuQABSAXg_GhkhZcC'),
7272
chat_id=12173560)
73-
self.assertEqual(u'AwADAQADIQEAAvjAuQABSAXg_GhkhZcC', message.audio.file_id)
73+
self.assertEqual('AwADAQADIQEAAvjAuQABSAXg_GhkhZcC', message.audio.file_id)
7474

7575
def testSendDocument(self):
7676
'''Test the telegram.Bot sendDocument method'''
77-
print 'Testing sendDocument - File'
77+
print('Testing sendDocument - File')
7878
message = self._bot.sendDocument(document=open('tests/telegram.png', 'rb'),
7979
chat_id=12173560)
8080
self.assertEqual(12948, message.document.file_size)
8181

8282
def testResendDocument(self):
8383
'''Test the telegram.Bot sendDocument method'''
84-
print 'Testing sendDocument - Resend'
84+
print('Testing sendDocument - Resend')
8585
message = self._bot.sendDocument(document=str('BQADAQADHAADNTwtBxZxUGKyxYbYAg'),
8686
chat_id=12173560)
87-
self.assertEqual(u'BQADAQADHAADNTwtBxZxUGKyxYbYAg', message.document.file_id)
87+
self.assertEqual('BQADAQADHAADNTwtBxZxUGKyxYbYAg', message.document.file_id)
8888

8989
def testResendSticker(self):
9090
'''Test the telegram.Bot sendSticker method'''
91-
print 'Testing sendSticker - Resend'
91+
print('Testing sendSticker - Resend')
9292
message = self._bot.sendSticker(sticker=str('BQADAQADHAADyIsGAAFZfq1bphjqlgI'),
9393
chat_id=12173560)
9494
self.assertEqual(39518, message.sticker.file_size)
9595

9696
def testSendVideo(self):
9797
'''Test the telegram.Bot sendVideo method'''
98-
print 'Testing sendVideo - File'
98+
print('Testing sendVideo - File')
9999
message = self._bot.sendVideo(video=open('tests/telegram.mp4', 'rb'),
100100
chat_id=12173560)
101101
self.assertEqual(326534, message.video.file_size)
102102

103103
def testResendVideo(self):
104104
'''Test the telegram.Bot sendVideo method'''
105-
print 'Testing sendVideo - Resend'
105+
print('Testing sendVideo - Resend')
106106
message = self._bot.sendVideo(video=str('BAADAQADIgEAAvjAuQABOuTB937fPTgC'),
107107
chat_id=12173560)
108108
self.assertEqual(4, message.video.duration)
109109

110110
def testSendLocation(self):
111111
'''Test the telegram.Bot sendLocation method'''
112-
print 'Testing sendLocation'
112+
print('Testing sendLocation')
113113
message = self._bot.sendLocation(latitude=-23.558873,
114114
longitude=-46.659732,
115115
chat_id=12173560)
@@ -118,12 +118,12 @@ def testSendLocation(self):
118118

119119
def testSendChatAction(self):
120120
'''Test the telegram.Bot sendChatAction method'''
121-
print 'Testing sendChatAction - ChatAction.TYPING'
121+
print('Testing sendChatAction - ChatAction.TYPING')
122122
self._bot.sendChatAction(action=telegram.ChatAction.TYPING,
123123
chat_id=12173560)
124124

125125
def testGetUserProfilePhotos(self):
126126
'''Test the telegram.Bot getUserProfilePhotos method'''
127-
print 'Testing getUserProfilePhotos'
127+
print('Testing getUserProfilePhotos')
128128
upf = self._bot.getUserProfilePhotos(user_id=12173560)
129129
self.assertEqual(8314, upf.photos[0][0].file_size)

0 commit comments

Comments
 (0)
X Tutup