Fixes + coverage

This commit is contained in:
JRoot Junior 2024-04-08 02:16:08 +03:00
parent c96a4fceca
commit 61d1bcdd96
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
14 changed files with 130 additions and 79 deletions

View file

@ -11,7 +11,9 @@ class TestAddStickerToSet:
response: bool = await bot.add_sticker_to_set(
user_id=42,
name="test stickers pack",
sticker=InputSticker(sticker="file id", format=StickerFormat.STATIC, emoji_list=[":)"]),
sticker=InputSticker(
sticker="file id", format=StickerFormat.STATIC, emoji_list=[":)"]
),
)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -14,7 +14,9 @@ class TestCreateNewStickerSet:
title="title",
stickers=[
InputSticker(sticker="file id", format=StickerFormat.STATIC, emoji_list=[":)"]),
InputSticker(sticker=FSInputFile("file.png"), format=StickerFormat.STATIC, emoji_list=["=("]),
InputSticker(
sticker=FSInputFile("file.png"), format=StickerFormat.STATIC, emoji_list=["=("]
),
],
sticker_format=StickerFormat.STATIC,
)

View file

@ -0,0 +1,24 @@
from aiogram.methods import GetBusinessConnection
from aiogram.types import BusinessConnection, User
from tests.mocked_bot import MockedBot
class TestGetBusinessConnection:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(
GetBusinessConnection,
ok=True,
result=BusinessConnection(
id="test",
user=User(id=42, is_bot=False, first_name="User"),
user_chat_id=42,
date=42,
can_reply=True,
is_enabled=True,
),
)
response: BusinessConnection = await bot.get_business_connection(
business_connection_id="test"
)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -0,0 +1,21 @@
from aiogram.methods import ReplaceStickerInSet
from aiogram.types import InputSticker
from tests.mocked_bot import MockedBot
class TestReplaceStickerInSet:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(ReplaceStickerInSet, ok=True, result=True)
response: bool = await bot.replace_sticker_in_set(
user_id=42,
name="test",
old_sticker="test",
sticker=InputSticker(
sticker="test",
format="static",
emoji_list=["test"],
),
)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -7,6 +7,8 @@ class TestSetStickerSetThumbnail:
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(SetStickerSetThumbnail, ok=True, result=None)
response: bool = await bot.set_sticker_set_thumbnail(name="test", format=StickerFormat.STATIC, user_id=42)
response: bool = await bot.set_sticker_set_thumbnail(
name="test", format=StickerFormat.STATIC, user_id=42
)
request = bot.get_request()
assert response == prepare_result.result

View file

@ -463,13 +463,6 @@ TEST_MESSAGE_USER_SHARED = Message(
from_user=User(id=42, is_bot=False, first_name="Test"),
user_shared=UserShared(request_id=42, user_id=42),
)
TEST_MESSAGE_SHARED_USER = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="User"),
shared_user=SharedUser(request_id=42, user_id=1),
)
TEST_MESSAGE_USERS_SHARED = Message(
message_id=42,
date=datetime.datetime.now(),
@ -493,8 +486,6 @@ TEST_MESSAGE_STORY = Message(
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="Test"),
story=Story(chat=Chat(id=42, type="private"), id=42),
forward_signature="Test",
forward_date=datetime.datetime.now(),
)
TEST_MESSAGE_GIVEAWAY = Message(
@ -535,13 +526,6 @@ TEST_MESSAGE_GIVEAWAY_COMPLETED = Message(
from_user=None,
giveaway_completed=GiveawayCompleted(winner_count=10),
)
TEST_MESSAGE_HAS_MEDIA_SPOILER = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=None,
has_media_spoiler=True,
)
TEST_MESSAGE_GENERAL_FORUM_TOPIC_HIDDEN = Message(
message_id=42,
date=datetime.datetime.now(),
@ -560,7 +544,6 @@ TEST_MESSAGE_WRITE_ACCESS_ALLOWED = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=None,
write_access_allowed=WriteAccessAllowed(),
)
TEST_MESSAGE_BOOST_ADDED = Message(
@ -570,27 +553,6 @@ TEST_MESSAGE_BOOST_ADDED = Message(
from_user=User(id=42, is_bot=False, first_name="User"),
boost_added=ChatBoostAdded(boost_count=1),
)
TEST_MESSAGE_BUSINESS_CONNECTION_ID = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="User"),
business_connection_id="idk"
)
TEST_MESSAGE_IS_FROM_OFFLINE = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=False, first_name="User"),
is_from_offline=True
)
TEST_MESSAGE_SENDER_BUSINESS_BOT = Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
from_user=User(id=42, is_bot=True, first_name="Bot"),
sender_business_bot=User(id=42, is_bot=True, first_name="Bot")
)
TEST_MESSAGE_UNKNOWN = Message(
message_id=42,
date=datetime.datetime.now(),
@ -649,20 +611,15 @@ MESSAGES_AND_CONTENT_TYPES = [
[TEST_MESSAGE_USER_SHARED, ContentType.USER_SHARED],
[TEST_MESSAGE_USERS_SHARED, ContentType.USERS_SHARED],
[TEST_CHAT_SHARED, ContentType.CHAT_SHARED],
[TEST_MESSAGE_SHARED_USER, ContentType.SHARED_USER],
[TEST_MESSAGE_STORY, ContentType.STORY],
[TEST_MESSAGE_GIVEAWAY, ContentType.GIVEAWAY],
[TEST_MESSAGE_GIVEAWAY_CREATED, ContentType.GIVEAWAY_CREATED],
[TEST_MESSAGE_GIVEAWAY_WINNERS, ContentType.GIVEAWAY_WINNERS],
[TEST_MESSAGE_GIVEAWAY_COMPLETED, ContentType.GIVEAWAY_COMPLETED],
[TEST_MESSAGE_HAS_MEDIA_SPOILER, ContentType.HAS_MEDIA_SPOILER],
[TEST_MESSAGE_GENERAL_FORUM_TOPIC_HIDDEN, ContentType.GENERAL_FORUM_TOPIC_HIDDEN],
[TEST_MESSAGE_GENERAL_FORUM_TOPIC_UNHIDDEN, ContentType.GENERAL_FORUM_TOPIC_UNHIDDEN],
[TEST_MESSAGE_WRITE_ACCESS_ALLOWED, ContentType.WRITE_ACCESS_ALLOWED],
[TEST_MESSAGE_BOOST_ADDED, ContentType.BOOST_ADDED],
[TEST_MESSAGE_BUSINESS_CONNECTION_ID, ContentType.BUSINESS_CONNECTION_ID],
[TEST_MESSAGE_IS_FROM_OFFLINE, ContentType.IS_FROM_OFFLINE],
[TEST_MESSAGE_SENDER_BUSINESS_BOT, ContentType.SENDER_BUSINESS_BOT],
[TEST_MESSAGE_UNKNOWN, ContentType.UNKNOWN],
]
@ -706,9 +663,7 @@ MESSAGES_AND_COPY_METHODS = [
[TEST_MESSAGE_DICE, SendDice],
[TEST_MESSAGE_USER_SHARED, None],
[TEST_CHAT_SHARED, None],
[TEST_MESSAGE_SHARED_USER, None],
[TEST_MESSAGE_GIVEAWAY_COMPLETED, None],
[TEST_MESSAGE_HAS_MEDIA_SPOILER, None],
[TEST_MESSAGE_WEB_APP_DATA, None],
[TEST_FORUM_TOPIC_CREATED, None],
[TEST_FORUM_TOPIC_EDITED, None],
@ -723,9 +678,6 @@ MESSAGES_AND_COPY_METHODS = [
[TEST_MESSAGE_GIVEAWAY, None],
[TEST_MESSAGE_GIVEAWAY_WINNERS, None],
[TEST_MESSAGE_BOOST_ADDED, None],
[TEST_MESSAGE_BUSINESS_CONNECTION_ID, None],
[TEST_MESSAGE_IS_FROM_OFFLINE, None],
[TEST_MESSAGE_SENDER_BUSINESS_BOT, None],
[TEST_MESSAGE_UNKNOWN, None],
]