|
22 | 22 | import io |
23 | 23 | import re |
24 | 24 | from datetime import datetime |
| 25 | +import time |
25 | 26 | import sys |
26 | 27 | import unittest |
27 | 28 |
|
@@ -161,7 +162,7 @@ def testSendBufferedReaderPhoto(self): |
161 | 162 | @flaky(3, 1) |
162 | 163 | @timeout(10) |
163 | 164 | def testSendGame(self): |
164 | | - game_short_name = 'pyhthon_telegram_bot_test_game' |
| 165 | + game_short_name = 'python_telegram_bot_test_game' |
165 | 166 | message = self._bot.sendGame(game_short_name=game_short_name, chat_id=self._chat_id) |
166 | 167 |
|
167 | 168 | self.assertTrue(self.is_json(message.to_json())) |
@@ -275,6 +276,26 @@ def test_get_webhook_info(self): |
275 | 276 | self._bot.set_webhook('') |
276 | 277 | self.assertEqual(url, info.url) |
277 | 278 |
|
| 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 | + |
278 | 299 | def _testUserEqualsBot(self, user): |
279 | 300 | """Tests if user is our trusty @PythonTelegramBot.""" |
280 | 301 | self.assertEqual(user.id, 133505823) |
|
0 commit comments