From 914004495619556db93a1b4eccce47edf229a4f2 Mon Sep 17 00:00:00 2001 From: Badiboy Date: Mon, 10 Jan 2022 16:49:49 +0300 Subject: [PATCH] Tests ant type hint fix --- telebot/__init__.py | 2 +- tests/test_telebot.py | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/telebot/__init__.py b/telebot/__init__.py index 5f299a659..5fed5c192 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -1929,7 +1929,7 @@ def set_my_commands(self, commands: List[types.BotCommand], return apihelper.set_my_commands(self.token, commands, scope, language_code) def delete_my_commands(self, scope: Optional[types.BotCommandScope]=None, - language_code: Optional[int]=None) -> bool: + language_code: Optional[str]=None) -> bool: """ Use this method to delete the list of the bot's commands for the given scope and user language. After deletion, higher level commands will be shown to affected users. diff --git a/tests/test_telebot.py b/tests/test_telebot.py index 1a4dc038a..54d380786 100644 --- a/tests/test_telebot.py +++ b/tests/test_telebot.py @@ -222,7 +222,7 @@ def test_send_photo_dis_noti(self): def test_send_audio(self): file_data = open('./test_data/record.mp3', 'rb') tb = telebot.TeleBot(TOKEN) - ret_msg = tb.send_audio(CHAT_ID, file_data, 1, performer='eternnoir', title='pyTelegram') + ret_msg = tb.send_audio(CHAT_ID, file_data, duration = 1, performer='eternnoir', title='pyTelegram') assert ret_msg.content_type == 'audio' assert ret_msg.audio.performer == 'eternnoir' assert ret_msg.audio.title == 'pyTelegram' @@ -230,7 +230,7 @@ def test_send_audio(self): 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, performer='eternnoir', title='pyTelegram', + ret_msg = tb.send_audio(CHAT_ID, file_data, duration = 1, performer='eternnoir', title='pyTelegram', disable_notification=True) assert ret_msg.content_type == 'audio' assert ret_msg.audio.performer == 'eternnoir' @@ -439,8 +439,10 @@ def test_export_chat_invite_link(self): def test_create_revoke_detailed_chat_invite_link(self): tb = telebot.TeleBot(TOKEN) - cil = tb.create_chat_invite_link(GROUP_ID, - (datetime.now() + timedelta(minutes=1)).timestamp(), member_limit=5) + cil = tb.create_chat_invite_link( + GROUP_ID, + expire_date = datetime.now() + timedelta(minutes=1), + member_limit=5) assert isinstance(cil.invite_link, str) assert cil.creator.id == tb.get_me().id assert isinstance(cil.expire_date, (float, int)) @@ -464,9 +466,10 @@ def test_edit_markup(self): def test_antiflood(self): text = "Flooding" tb = telebot.TeleBot(TOKEN) - for _ in range(0,100): + i = -1 + for i in range(0,100): util.antiflood(tb.send_message, CHAT_ID, text) - assert _ + assert i @staticmethod def create_text_message(text): @@ -585,14 +588,14 @@ def test_chat_commands(self): ret_msg = tb.set_my_commands([telebot.types.BotCommand(command, description)], scope, lang) assert ret_msg is True - ret_msg = tb.get_my_commands(scope, lang) + ret_msg = tb.get_my_commands(scope = scope, language_code = lang) assert ret_msg[0].command == command assert ret_msg[0].description == description - ret_msg = tb.delete_my_commands(scope, lang) + ret_msg = tb.delete_my_commands(scope = scope, language_code = lang) assert ret_msg is True - ret_msg = tb.get_my_commands(scope, lang) + ret_msg = tb.get_my_commands(scope = scope, language_code = lang) assert ret_msg == []