diff --git a/tests/test_telebot.py b/tests/test_telebot.py index 3af6a03..349c63d 100644 --- a/tests/test_telebot.py +++ b/tests/test_telebot.py @@ -6,6 +6,10 @@ sys.path.append('../') from telebot import types from telebot import apihelper import telebot +import os + +TOKEN = os.environ['TOKEN'] +CHAT_ID = os.environ['CHAT_ID'] def test_message_listener(): @@ -33,9 +37,68 @@ def test_message_handler(): assert msg.text == 'got' +def test_send_file_by_id(): + 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(): + file_data = open('../examples/detailed_example/kitten.jpg') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_document(CHAT_ID, file_data) + assert ret_msg.message_id + + +def test_send_photo_by_id(): + 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(): + file_data = open('../examples/detailed_example/kitten.jpg') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_photo(CHAT_ID, file_data) + assert ret_msg.message_id + + +def test_send_message(): + text = 'CI Test Message' + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_message(CHAT_ID, text) + assert ret_msg.message_id + + +def test_forward_message(): + text = 'CI forward_message Test Message' + tb = telebot.TeleBot(TOKEN) + msg = tb.send_message(CHAT_ID, text) + ret_msg = tb.forward_message(CHAT_ID, CHAT_ID, msg.message_id) + assert ret_msg.forward_from + + +def test_reply_to(): + text = 'CI reply_to Test Message' + tb = telebot.TeleBot(TOKEN) + msg = tb.send_message(CHAT_ID, text) + ret_msg = tb.reply_to(msg, text + ' REPLY') + assert ret_msg.reply_to_message.message_id == msg.message_id + + +def test_send_location(): + tb = telebot.TeleBot(TOKEN) + lat = 26.3875591 + lon = -161.2901042 + ret_msg = tb.send_location(CHAT_ID, lat, lon) + assert int(ret_msg.location.longitude) == int(lon) + assert int(ret_msg.location.latitude) == int(lat) + + def create_text_message(text): - params = {} - params['text'] = text + params = {'text': text} return types.Message(1, None, None, 1, 'text', params)