X Tutup
Skip to content

Commit 7ad92dc

Browse files
committed
Add test for set_game_score
1 parent d1ddfad commit 7ad92dc

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

tests/test_bot.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import io
2323
import re
2424
from datetime import datetime
25+
import time
2526
import sys
2627
import unittest
2728

@@ -161,7 +162,7 @@ def testSendBufferedReaderPhoto(self):
161162
@flaky(3, 1)
162163
@timeout(10)
163164
def testSendGame(self):
164-
game_short_name = 'pyhthon_telegram_bot_test_game'
165+
game_short_name = 'python_telegram_bot_test_game'
165166
message = self._bot.sendGame(game_short_name=game_short_name, chat_id=self._chat_id)
166167

167168
self.assertTrue(self.is_json(message.to_json()))
@@ -275,6 +276,26 @@ def test_get_webhook_info(self):
275276
self._bot.set_webhook('')
276277
self.assertEqual(url, info.url)
277278

279+
@flaky(3, 1)
280+
@timeout(10)
281+
def test_set_game_score(self):
282+
# We need a game to set the score for
283+
game_short_name = 'python_telegram_bot_test_game'
284+
game = self._bot.sendGame(game_short_name=game_short_name, chat_id=self._chat_id)
285+
286+
message = self._bot.set_game_score(
287+
user_id=self._chat_id,
288+
score=int(time.time() - 1450000000),
289+
chat_id=game.chat_id,
290+
message_id=game.message_id,
291+
edit_message=True)
292+
293+
self.assertTrue(self.is_json(game.to_json()))
294+
self.assertEqual(message.game.description, game.game.description)
295+
self.assertEqual(message.game.animation.file_id, game.game.animation)
296+
self.assertEqual(message.game.photo[0].file_size, game.game.photo[0].file_size)
297+
self.assertNotEqual(message.game.text, game.game.text)
298+
278299
def _testUserEqualsBot(self, user):
279300
"""Tests if user is our trusty @PythonTelegramBot."""
280301
self.assertEqual(user.id, 133505823)

0 commit comments

Comments
 (0)
X Tutup