Adding sendPhoto method by file_id

This commit is contained in:
Leandro Toledo 2015-07-07 19:06:17 -03:00
parent f7a15306a8
commit 5e2f60ed7d
2 changed files with 10 additions and 3 deletions

View file

@ -144,7 +144,7 @@ class Bot(object):
data=None): data=None):
if method == 'POST': if method == 'POST':
if data.has_key('photo'): if data.has_key('photo') and isinstance(data['photo'], file):
try: try:
photo = data.pop('photo') photo = data.pop('photo')

View file

@ -46,7 +46,14 @@ class BotTest(unittest.TestCase):
def testSendPhoto(self): def testSendPhoto(self):
'''Test the telegram.Bot sendPhoto method''' '''Test the telegram.Bot sendPhoto method'''
print 'Testing sendPhoto' print 'Testing sendPhoto - File'
message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'), message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'),
chat_id=12173560) 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'))