diff --git a/telegram/bot.py b/telegram/bot.py index 78ffb61a5..0874ac31e 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -144,7 +144,7 @@ class Bot(object): data=None): if method == 'POST': - if data.has_key('photo'): + if data.has_key('photo') and isinstance(data['photo'], file): try: photo = data.pop('photo') diff --git a/tests/test_bot.py b/tests/test_bot.py index 485f5cf74..9d93b9376 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -46,7 +46,14 @@ class BotTest(unittest.TestCase): def testSendPhoto(self): '''Test the telegram.Bot sendPhoto method''' - print 'Testing sendPhoto' + print 'Testing sendPhoto - File' message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'), chat_id=12173560) - #self.assertEqual(u'') + self.assertEqual(12948, message.photo[2].get('file_size')) + + def testReSendPhoto(self): + '''Test the telegram.Bot sendPhoto method''' + print 'Testing sendPhoto - Resend' + message = self._bot.sendPhoto(photo=str('AgAD_v___6-nMRs1PC0HuqtHTCQ9qx0AFAI'), + chat_id=12173560) + self.assertEqual(u'AgAD_v___6-nMRs1PC0HuqtHTCQ9qx0AFAI', message.photo[2].get('file_id'))