diff --git a/tests/test_telebot.py b/tests/test_telebot.py index dec456a..e0e23ea 100644 --- a/tests/test_telebot.py +++ b/tests/test_telebot.py @@ -101,6 +101,16 @@ class TestTeleBot: ret_msg = tb.send_message(CHAT_ID, markdown, parse_mode="Markdown") assert ret_msg.message_id + def test_send_message_with_disable_notification(self): + tb = telebot.TeleBot(TOKEN) + markdown = """ + *bold text* + _italic text_ + [text](URL) + """ + ret_msg = tb.send_message(CHAT_ID, markdown, parse_mode="Markdown", disable_notification=True) + assert ret_msg.message_id + def test_send_file(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') tb = telebot.TeleBot(TOKEN) @@ -110,18 +120,39 @@ class TestTeleBot: ret_msg = tb.send_document(CHAT_ID, ret_msg.document.file_id) assert ret_msg.message_id + def test_send_file_dis_noti(self): + file_data = open('../examples/detailed_example/kitten.jpg', 'rb') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_document(CHAT_ID, file_data, disable_notification=True) + 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) ret_msg = tb.send_video(CHAT_ID, file_data) assert ret_msg.message_id + def test_send_video_dis_noti(self): + file_data = open('./test_data/test_video.mp4', 'rb') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_video(CHAT_ID, file_data, disable_notification=True) + assert ret_msg.message_id + def test_send_video_more_params(self): file_data = open('./test_data/test_video.mp4', 'rb') tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_video(CHAT_ID, file_data, 1) assert ret_msg.message_id + def test_send_video_more_params_dis_noti(self): + file_data = open('./test_data/test_video.mp4', 'rb') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_video(CHAT_ID, file_data, 1, disable_notification=True) + assert ret_msg.message_id + def test_send_file_exception(self): tb = telebot.TeleBot(TOKEN) try: @@ -140,6 +171,15 @@ class TestTeleBot: ret_msg = tb.send_photo(CHAT_ID, ret_msg.photo[0].file_id) assert ret_msg.message_id + def test_send_photo_dis_noti(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, disable_notification=True) + assert ret_msg.message_id + def test_send_audio(self): file_data = open('./test_data/record.mp3', 'rb') tb = telebot.TeleBot(TOKEN) @@ -148,12 +188,26 @@ class TestTeleBot: assert ret_msg.audio.performer == 'eternnoir' assert ret_msg.audio.title == 'pyTelegram' + def test_send_audio_dis_noti(self): + file_data = open('./test_data/record.mp3', 'rb') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_audio(CHAT_ID, file_data, 1, 'eternnoir', 'pyTelegram', disable_notification=True) + assert ret_msg.content_type == 'audio' + assert ret_msg.audio.performer == 'eternnoir' + assert ret_msg.audio.title == 'pyTelegram' + def test_send_voice(self): file_data = open('./test_data/record.ogg', 'rb') tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_voice(CHAT_ID, file_data) assert ret_msg.voice.mime_type == 'audio/ogg' + def test_send_voice_dis_noti(self): + file_data = open('./test_data/record.ogg', 'rb') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_voice(CHAT_ID, file_data, disable_notification=True) + assert ret_msg.voice.mime_type == 'audio/ogg' + def test_get_file(self): file_data = open('./test_data/record.ogg', 'rb') tb = telebot.TeleBot(TOKEN) @@ -162,12 +216,26 @@ class TestTeleBot: file_info = tb.get_file(file_id) assert file_info.file_id == file_id + def test_get_file_dis_noti(self): + file_data = open('./test_data/record.ogg', 'rb') + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_voice(CHAT_ID, file_data, disable_notification=True) + file_id = ret_msg.voice.file_id + file_info = tb.get_file(file_id) + assert file_info.file_id == file_id + def test_send_message(self): text = 'CI Test Message' tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_message(CHAT_ID, text) assert ret_msg.message_id + def test_send_message_dis_noti(self): + text = 'CI Test Message' + tb = telebot.TeleBot(TOKEN) + ret_msg = tb.send_message(CHAT_ID, text, disable_notification=True) + assert ret_msg.message_id + def test_forward_message(self): text = 'CI forward_message Test Message' tb = telebot.TeleBot(TOKEN) @@ -175,6 +243,13 @@ class TestTeleBot: ret_msg = tb.forward_message(CHAT_ID, CHAT_ID, msg.message_id) assert ret_msg.forward_from + def test_forward_message_dis_noti(self): + 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, disable_notification=True) + assert ret_msg.forward_from + def test_reply_to(self): text = 'CI reply_to Test Message' tb = telebot.TeleBot(TOKEN) @@ -203,6 +278,14 @@ class TestTeleBot: assert int(ret_msg.location.longitude) == int(lon) assert int(ret_msg.location.latitude) == int(lat) + def test_send_location_dis_noti(self): + tb = telebot.TeleBot(TOKEN) + lat = 26.3875591 + lon = -161.2901042 + ret_msg = tb.send_location(CHAT_ID, lat, lon, disable_notification=True) + assert int(ret_msg.location.longitude) == int(lon) + assert int(ret_msg.location.latitude) == int(lat) + def test_Chat(self): tb = telebot.TeleBot(TOKEN) me = tb.get_me()