Remove assert statement from non-test files

This commit is contained in:
deepsource-autofix[bot] 2020-11-08 21:48:49 +00:00 committed by GitHub
parent 44cd1fd974
commit dd50a9b13e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 637 additions and 323 deletions

View file

@ -22,7 +22,8 @@ async def test_get_me(bot: Bot, event_loop):
async with FakeTelegram(message_data=USER, loop=event_loop):
result = await bot.me
assert result == user
if result != user:
raise AssertionError
async def test_log_out(bot: Bot, event_loop):
@ -30,7 +31,8 @@ async def test_log_out(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.log_out()
assert result is True
if result is not True:
raise AssertionError
async def test_close_bot(bot: Bot, event_loop):
@ -38,7 +40,8 @@ async def test_close_bot(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.close_bot()
assert result is True
if result is not True:
raise AssertionError
async def test_send_message(bot: Bot, event_loop):
@ -48,7 +51,8 @@ async def test_send_message(bot: Bot, event_loop):
async with FakeTelegram(message_data=MESSAGE, loop=event_loop):
result = await bot.send_message(chat_id=msg.chat.id, text=msg.text)
assert result == msg
if result != msg:
raise AssertionError
async def test_forward_message(bot: Bot, event_loop):
@ -59,7 +63,8 @@ async def test_forward_message(bot: Bot, event_loop):
async with FakeTelegram(message_data=FORWARDED_MESSAGE, loop=event_loop):
result = await bot.forward_message(chat_id=msg.chat.id, from_chat_id=msg.forward_from_chat.id,
message_id=msg.forward_from_message_id)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_photo(bot: Bot, event_loop):
@ -71,7 +76,8 @@ async def test_send_photo(bot: Bot, event_loop):
async with FakeTelegram(message_data=MESSAGE_WITH_PHOTO, loop=event_loop):
result = await bot.send_photo(msg.chat.id, photo=photo.file_id, caption=msg.caption,
parse_mode=types.ParseMode.HTML, disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_audio(bot: Bot, event_loop):
@ -83,7 +89,8 @@ async def test_send_audio(bot: Bot, event_loop):
result = await bot.send_audio(chat_id=msg.chat.id, audio=msg.audio.file_id, caption=msg.caption,
parse_mode=types.ParseMode.HTML, duration=msg.audio.duration,
performer=msg.audio.performer, title=msg.audio.title, disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_document(bot: Bot, event_loop):
@ -94,7 +101,8 @@ async def test_send_document(bot: Bot, event_loop):
async with FakeTelegram(message_data=MESSAGE_WITH_DOCUMENT, loop=event_loop):
result = await bot.send_document(chat_id=msg.chat.id, document=msg.document.file_id, caption=msg.caption,
parse_mode=types.ParseMode.HTML, disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_video(bot: Bot, event_loop):
@ -108,7 +116,8 @@ async def test_send_video(bot: Bot, event_loop):
width=video.width, height=video.height, caption=msg.caption,
parse_mode=types.ParseMode.HTML, supports_streaming=True,
disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_voice(bot: Bot, event_loop):
@ -121,7 +130,8 @@ async def test_send_voice(bot: Bot, event_loop):
result = await bot.send_voice(chat_id=msg.chat.id, voice=voice.file_id, caption=msg.caption,
parse_mode=types.ParseMode.HTML, duration=voice.duration,
disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_video_note(bot: Bot, event_loop):
@ -134,7 +144,8 @@ async def test_send_video_note(bot: Bot, event_loop):
result = await bot.send_video_note(chat_id=msg.chat.id, video_note=video_note.file_id,
duration=video_note.duration, length=video_note.length,
disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_media_group(bot: Bot, event_loop):
@ -146,8 +157,10 @@ async def test_send_media_group(bot: Bot, event_loop):
async with FakeTelegram(message_data=[MESSAGE_WITH_MEDIA_GROUP, MESSAGE_WITH_MEDIA_GROUP], loop=event_loop):
result = await bot.send_media_group(msg.chat.id, media=media, disable_notification=False)
assert len(result) == len(media)
assert result.pop().media_group_id
if len(result) != len(media):
raise AssertionError
if not result.pop().media_group_id:
raise AssertionError
async def test_send_location(bot: Bot, event_loop):
@ -159,7 +172,8 @@ async def test_send_location(bot: Bot, event_loop):
async with FakeTelegram(message_data=MESSAGE_WITH_LOCATION, loop=event_loop):
result = await bot.send_location(msg.chat.id, latitude=location.latitude, longitude=location.longitude,
live_period=10, disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_edit_message_live_location_by_bot(bot: Bot, event_loop):
@ -172,7 +186,8 @@ async def test_edit_message_live_location_by_bot(bot: Bot, event_loop):
async with FakeTelegram(message_data=MESSAGE_WITH_LOCATION, loop=event_loop):
result = await bot.edit_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id,
latitude=location.latitude, longitude=location.longitude)
assert result == msg
if result != msg:
raise AssertionError
async def test_edit_message_live_location_by_user(bot: Bot, event_loop):
@ -185,7 +200,8 @@ async def test_edit_message_live_location_by_user(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.edit_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id,
latitude=location.latitude, longitude=location.longitude)
assert isinstance(result, bool) and result is True
if not (isinstance(result, bool) and result is True):
raise AssertionError
async def test_stop_message_live_location_by_bot(bot: Bot, event_loop):
@ -196,7 +212,8 @@ async def test_stop_message_live_location_by_bot(bot: Bot, event_loop):
# stopping bot message
async with FakeTelegram(message_data=MESSAGE_WITH_LOCATION, loop=event_loop):
result = await bot.stop_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id)
assert result == msg
if result != msg:
raise AssertionError
async def test_stop_message_live_location_by_user(bot: Bot, event_loop):
@ -207,8 +224,10 @@ async def test_stop_message_live_location_by_user(bot: Bot, event_loop):
# stopping user's message
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.stop_message_live_location(chat_id=msg.chat.id, message_id=msg.message_id)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_send_venue(bot: Bot, event_loop):
@ -222,7 +241,8 @@ async def test_send_venue(bot: Bot, event_loop):
result = await bot.send_venue(msg.chat.id, latitude=location.latitude, longitude=location.longitude,
title=venue.title, address=venue.address, foursquare_id=venue.foursquare_id,
disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_contact(bot: Bot, event_loop):
@ -234,7 +254,8 @@ async def test_send_contact(bot: Bot, event_loop):
async with FakeTelegram(message_data=MESSAGE_WITH_CONTACT, loop=event_loop):
result = await bot.send_contact(msg.chat.id, phone_number=contact.phone_number, first_name=contact.first_name,
last_name=contact.last_name, disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_dice(bot: Bot, event_loop):
@ -244,7 +265,8 @@ async def test_send_dice(bot: Bot, event_loop):
async with FakeTelegram(message_data=MESSAGE_WITH_DICE, loop=event_loop):
result = await bot.send_dice(msg.chat.id, disable_notification=False)
assert result == msg
if result != msg:
raise AssertionError
async def test_send_chat_action(bot: Bot, event_loop):
@ -254,8 +276,10 @@ async def test_send_chat_action(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.send_chat_action(chat_id=chat.id, action=types.ChatActions.TYPING)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_get_user_profile_photo(bot: Bot, event_loop):
@ -265,7 +289,8 @@ async def test_get_user_profile_photo(bot: Bot, event_loop):
async with FakeTelegram(message_data=USER_PROFILE_PHOTOS, loop=event_loop):
result = await bot.get_user_profile_photos(user_id=user.id, offset=1, limit=1)
assert isinstance(result, types.UserProfilePhotos)
if not isinstance(result, types.UserProfilePhotos):
raise AssertionError
async def test_get_file(bot: Bot, event_loop):
@ -275,7 +300,8 @@ async def test_get_file(bot: Bot, event_loop):
async with FakeTelegram(message_data=FILE, loop=event_loop):
result = await bot.get_file(file_id=file.file_id)
assert isinstance(result, types.File)
if not isinstance(result, types.File):
raise AssertionError
async def test_kick_chat_member(bot: Bot, event_loop):
@ -286,8 +312,10 @@ async def test_kick_chat_member(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.kick_chat_member(chat_id=chat.id, user_id=user.id, until_date=123)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_unban_chat_member(bot: Bot, event_loop):
@ -298,8 +326,10 @@ async def test_unban_chat_member(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.unban_chat_member(chat_id=chat.id, user_id=user.id)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_restrict_chat_member(bot: Bot, event_loop):
@ -318,8 +348,10 @@ async def test_restrict_chat_member(bot: Bot, event_loop):
can_send_messages=False,
can_send_other_messages=False
), until_date=123)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_promote_chat_member(bot: Bot, event_loop):
@ -333,8 +365,10 @@ async def test_promote_chat_member(bot: Bot, event_loop):
can_delete_messages=True, can_edit_messages=True,
can_invite_users=True, can_pin_messages=True, can_post_messages=True,
can_promote_members=True, can_restrict_members=True)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_export_chat_invite_link(bot: Bot, event_loop):
@ -344,7 +378,8 @@ async def test_export_chat_invite_link(bot: Bot, event_loop):
async with FakeTelegram(message_data=INVITE_LINK, loop=event_loop):
result = await bot.export_chat_invite_link(chat_id=chat.id)
assert result == INVITE_LINK
if result != INVITE_LINK:
raise AssertionError
async def test_delete_chat_photo(bot: Bot, event_loop):
@ -354,8 +389,10 @@ async def test_delete_chat_photo(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.delete_chat_photo(chat_id=chat.id)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_set_chat_title(bot: Bot, event_loop):
@ -365,8 +402,10 @@ async def test_set_chat_title(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.set_chat_title(chat_id=chat.id, title='Test title')
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_set_chat_description(bot: Bot, event_loop):
@ -376,8 +415,10 @@ async def test_set_chat_description(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.set_chat_description(chat_id=chat.id, description='Test description')
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_pin_chat_message(bot: Bot, event_loop):
@ -388,8 +429,10 @@ async def test_pin_chat_message(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.pin_chat_message(chat_id=message.chat.id, message_id=message.message_id,
disable_notification=False)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_unpin_chat_message(bot: Bot, event_loop):
@ -399,8 +442,10 @@ async def test_unpin_chat_message(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.unpin_chat_message(chat_id=chat.id)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_leave_chat(bot: Bot, event_loop):
@ -410,8 +455,10 @@ async def test_leave_chat(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.leave_chat(chat_id=chat.id)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_get_chat(bot: Bot, event_loop):
@ -421,7 +468,8 @@ async def test_get_chat(bot: Bot, event_loop):
async with FakeTelegram(message_data=CHAT, loop=event_loop):
result = await bot.get_chat(chat_id=chat.id)
assert result == chat
if result != chat:
raise AssertionError
async def test_get_chat_administrators(bot: Bot, event_loop):
@ -432,8 +480,10 @@ async def test_get_chat_administrators(bot: Bot, event_loop):
async with FakeTelegram(message_data=[CHAT_MEMBER, CHAT_MEMBER], loop=event_loop):
result = await bot.get_chat_administrators(chat_id=chat.id)
assert result[0] == member
assert len(result) == 2
if result[0] != member:
raise AssertionError
if len(result) != 2:
raise AssertionError
async def test_get_chat_members_count(bot: Bot, event_loop):
@ -444,7 +494,8 @@ async def test_get_chat_members_count(bot: Bot, event_loop):
async with FakeTelegram(message_data=count, loop=event_loop):
result = await bot.get_chat_members_count(chat_id=chat.id)
assert result == count
if result != count:
raise AssertionError
async def test_get_chat_member(bot: Bot, event_loop):
@ -455,8 +506,10 @@ async def test_get_chat_member(bot: Bot, event_loop):
async with FakeTelegram(message_data=CHAT_MEMBER, loop=event_loop):
result = await bot.get_chat_member(chat_id=chat.id, user_id=member.user.id)
assert isinstance(result, types.ChatMember)
assert result == member
if not isinstance(result, types.ChatMember):
raise AssertionError
if result != member:
raise AssertionError
async def test_set_chat_sticker_set(bot: Bot, event_loop):
@ -466,8 +519,10 @@ async def test_set_chat_sticker_set(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.set_chat_sticker_set(chat_id=chat.id, sticker_set_name='aiogram_stickers')
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_delete_chat_sticker_set(bot: Bot, event_loop):
@ -477,8 +532,10 @@ async def test_delete_chat_sticker_set(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.delete_chat_sticker_set(chat_id=chat.id)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_answer_callback_query(bot: Bot, event_loop):
@ -486,8 +543,10 @@ async def test_answer_callback_query(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.answer_callback_query(callback_query_id='QuERyId', text='Test Answer')
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_set_my_commands(bot: Bot, event_loop):
@ -497,8 +556,10 @@ async def test_set_my_commands(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
commands = [types.BotCommand(**BOT_COMMAND), types.BotCommand(**BOT_COMMAND)]
result = await bot.set_my_commands(commands)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_get_my_commands(bot: Bot, event_loop):
@ -508,8 +569,10 @@ async def test_get_my_commands(bot: Bot, event_loop):
commands = [command, command]
async with FakeTelegram(message_data=commands, loop=event_loop):
result = await bot.get_my_commands()
assert isinstance(result, list)
assert all(isinstance(command, types.BotCommand) for command in result)
if not isinstance(result, list):
raise AssertionError
if not all(isinstance(command, types.BotCommand) for command in result):
raise AssertionError
async def test_edit_message_text_by_bot(bot: Bot, event_loop):
@ -520,7 +583,8 @@ async def test_edit_message_text_by_bot(bot: Bot, event_loop):
# message by bot
async with FakeTelegram(message_data=EDITED_MESSAGE, loop=event_loop):
result = await bot.edit_message_text(text=msg.text, chat_id=msg.chat.id, message_id=msg.message_id)
assert result == msg
if result != msg:
raise AssertionError
async def test_edit_message_text_by_user(bot: Bot, event_loop):
@ -531,8 +595,10 @@ async def test_edit_message_text_by_user(bot: Bot, event_loop):
# message by user
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.edit_message_text(text=msg.text, chat_id=msg.chat.id, message_id=msg.message_id)
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_set_sticker_set_thumb(bot: Bot, event_loop):
@ -540,11 +606,14 @@ async def test_set_sticker_set_thumb(bot: Bot, event_loop):
async with FakeTelegram(message_data=True, loop=event_loop):
result = await bot.set_sticker_set_thumb(name='test', user_id=123456789, thumb='file_id')
assert isinstance(result, bool)
assert result is True
if not isinstance(result, bool):
raise AssertionError
if result is not True:
raise AssertionError
async def test_bot_id(bot: Bot):
""" Check getting id from token. """
bot = Bot(TOKEN)
assert bot.id == BOT_ID # BOT_ID is a correct id from TOKEN
if bot.id != BOT_ID:
raise AssertionError