diff --git a/aiogram/enums/__init__.py b/aiogram/enums/__init__.py index 7d70d0c9..a744ba55 100644 --- a/aiogram/enums/__init__.py +++ b/aiogram/enums/__init__.py @@ -11,6 +11,7 @@ from .menu_button_type import MenuButtonType from .message_entity_type import MessageEntityType from .parse_mode import ParseMode from .poll_type import PollType +from .sticker_type import StickerType from .topic_icon_color import TopicIconColor from .update_type import UpdateType @@ -28,6 +29,7 @@ __all__ = ( "MessageEntityType", "ParseMode", "PollType", + "StickerType", "TopicIconColor", "UpdateType", ) diff --git a/tests/test_api/test_types/test_chat.py b/tests/test_api/test_types/test_chat.py index e2f6bdca..03cb8963 100644 --- a/tests/test_api/test_types/test_chat.py +++ b/tests/test_api/test_types/test_chat.py @@ -2,7 +2,8 @@ from typing import Optional from pytest import mark, param -from aiogram.types import Chat +from aiogram.enums import ChatAction +from aiogram.types import BufferedInputFile, Chat, ChatPermissions class TestChat: @@ -20,6 +21,172 @@ class TestChat: assert method.chat_id == chat.id assert method.sender_chat_id == -1337 + def test_get_administrators(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.get_administrators() + assert method.chat_id == chat.id + + def test_delete_message(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.delete_message(message_id=1) + assert method.chat_id == chat.id + + def test_revoke_invite_link(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.revoke_invite_link(invite_link="test") + assert method.chat_id == chat.id + + def test_edit_invite_link(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.edit_invite_link(invite_link="test", name="test") + assert method.chat_id == chat.id + + def test_create_invite_link(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.create_invite_link(name="test") + assert method.chat_id == chat.id + + def test_export_invite_link(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.export_invite_link() + assert method.chat_id == chat.id + + def test_do(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.do(ChatAction.TYPING) + assert method.chat_id == chat.id + + def test_delete_sticker_set(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.delete_sticker_set() + assert method.chat_id == chat.id + + def test_set_sticker_set(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.set_sticker_set(sticker_set_name="test") + assert method.chat_id == chat.id + + def test_get_member(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.get_member(user_id=42) + assert method.chat_id == chat.id + + def test_get_member_count(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.get_member_count() + assert method.chat_id == chat.id + + def test_leave(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.leave() + assert method.chat_id == chat.id + + def test_unpin_all_messages(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.unpin_all_messages() + assert method.chat_id == chat.id + + def test_unpin_message(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.unpin_message() + assert method.chat_id == chat.id + + def test_pin_message(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.pin_message(message_id=1) + assert method.chat_id == chat.id + + def test_set_administrator_custom_title(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.set_administrator_custom_title(user_id=1, custom_title="test") + assert method.chat_id == chat.id + + def test_set_permissions(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.set_permissions( + permissions=ChatPermissions( + can_send_messages=True, + ) + ) + assert method.chat_id == chat.id + + def test_promote(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.promote( + user_id=42, + can_manage_chat=True, + ) + assert method.chat_id == chat.id + + def test_restrict(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.restrict( + user_id=42, + permissions=ChatPermissions( + can_send_messages=True, + ), + ) + assert method.chat_id == chat.id + + def test_unban(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.unban( + user_id=42, + ) + assert method.chat_id == chat.id + + def test_ban(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.ban( + user_id=42, + ) + assert method.chat_id == chat.id + + def test_set_description(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.set_description(description="test") + assert method.chat_id == chat.id + + def test_set_title(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.set_title(title="test") + assert method.chat_id == chat.id + + def test_delete_photo(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.delete_photo(description="test") + assert method.chat_id == chat.id + + def test_set_photo(self): + chat = Chat(id=-42, type="supergroup") + + method = chat.set_photo(photo=BufferedInputFile(b"PNG", filename="photo.png")) + assert method.chat_id == chat.id + @mark.parametrize( "first,last,title,chat_type,result", [ diff --git a/tests/test_api/test_types/test_sticker.py b/tests/test_api/test_types/test_sticker.py new file mode 100644 index 00000000..6adce4ea --- /dev/null +++ b/tests/test_api/test_types/test_sticker.py @@ -0,0 +1,32 @@ +from aiogram.enums import StickerType +from aiogram.types import Sticker + + +class TestSticker: + def test_get_profile_photos(self): + sticker = Sticker( + file_id="test", + file_unique_id="test", + type=StickerType.REGULAR, + width=100, + height=100, + is_animated=False, + is_video=False, + ) + + method = sticker.set_position_in_set(position=1) + assert method.sticker == sticker.file_id + + def test_delete_from_set(self): + sticker = Sticker( + file_id="test", + file_unique_id="test", + type=StickerType.REGULAR, + width=100, + height=100, + is_animated=False, + is_video=False, + ) + + method = sticker.delete_from_set() + assert method.sticker == sticker.file_id diff --git a/tests/test_api/test_types/test_user.py b/tests/test_api/test_types/test_user.py index c57c0704..9f28175b 100644 --- a/tests/test_api/test_types/test_user.py +++ b/tests/test_api/test_types/test_user.py @@ -50,3 +50,9 @@ class TestUser: user = User(id=42, is_bot=False, first_name=first, last_name=last) assert user.mention_html() == f'{user.full_name}' assert user.mention_html(name=name) == f'{name}' + + def test_get_profile_photos(self): + user = User(id=42, is_bot=False, first_name="Test", last_name="User") + + method = user.get_profile_photos(description="test") + assert method.user_id == user.id