1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Created util.py to clean up __init__.py and apihelper.py and updated README accordingly

Fixed failing send_document_by_id and send_photo_by_id
This commit is contained in:
pieter
2015-08-31 11:46:18 +02:00
parent 6f34a22c4b
commit 3c8faa155f
6 changed files with 161 additions and 171 deletions

View File

@ -9,6 +9,7 @@ import os
import telebot
from telebot import types
from telebot import apihelper
from telebot import util
should_skip = 'TOKEN' and 'CHAT_ID' not in os.environ
@ -67,18 +68,15 @@ class TestTeleBot:
time.sleep(1)
assert not msg.text == 'got'
def test_send_file_by_id(self):
file_id = 'BQADBQADjAIAAsYifgbvqwq1he9REAI'
tb = telebot.TeleBot(TOKEN)
ret_msg = tb.send_document(CHAT_ID, file_id)
assert ret_msg.message_id
def test_send_file(self):
file_data = open('../examples/detailed_example/kitten.jpg', 'rb')
tb = telebot.TeleBot(TOKEN)
ret_msg = tb.send_document(CHAT_ID, file_data)
assert ret_msg.message_id
ret_msg = tb.send_document(CHAT_ID, ret_msg.document.file_id)
assert ret_msg.message_id
def test_send_video(self):
file_data = open('./test_data/test_video.mp4', 'rb')
tb = telebot.TeleBot(TOKEN)
@ -100,18 +98,15 @@ class TestTeleBot:
print(e)
assert True
def test_send_photo_by_id(self):
photo_id = 'AgADBQADTKgxG8YifgbcWQAB7Da9yYIx1rEyAAT-HYJ3CrJEqdA2AQABAg'
tb = telebot.TeleBot(TOKEN)
ret_msg = tb.send_photo(CHAT_ID, photo_id)
assert ret_msg.message_id
def test_send_photo(self):
file_data = open('../examples/detailed_example/kitten.jpg', 'rb')
tb = telebot.TeleBot(TOKEN)
ret_msg = tb.send_photo(CHAT_ID, file_data)
assert ret_msg.message_id
ret_msg = tb.send_photo(CHAT_ID, ret_msg.photo[0].file_id)
assert ret_msg.message_id
def test_send_audio(self):
file_data = open('./test_data/record.mp3', 'rb')
tb = telebot.TeleBot(TOKEN)
@ -174,12 +169,12 @@ class TestTeleBot:
def test_is_string_unicode(self):
s1 = u'string'
assert apihelper.is_string(s1)
assert util.is_string(s1)
def test_is_string_string(self):
s1 = 'string'
assert apihelper.is_string(s1)
assert util.is_string(s1)
def test_not_string(self):
i1 = 10
assert not apihelper.is_string(i1)
assert not util.is_string(i1)