From 1c898ae3173a3ab3b5407f3f36ab7e00da3ce2d8 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Mon, 10 Jan 2022 11:30:02 +0300 Subject: [PATCH] chore: add update_chat test --- tests/types/dataset.py | 42 ++++++++++++++++++++++++++++++++++++++++ tests/types/test_chat.py | 16 +++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/tests/types/dataset.py b/tests/types/dataset.py index be23da9e..13763421 100644 --- a/tests/types/dataset.py +++ b/tests/types/dataset.py @@ -19,6 +19,14 @@ CHAT = { "type": "private", } +CHAT_PHOTO = { + "small_file_id": 1, + "small_file_unique_id": 1, + "big_file_id": 1, + "big_file_unique_id": 1, +} + + PHOTO = { "file_id": "AgADBAADFak0G88YZAf8OAug7bHyS9x2ZxkABHVfpJywcloRAAGAAQABAg", "file_size": 1101, @@ -485,3 +493,37 @@ REPLY_KEYBOARD_MARKUP = { "keyboard": [[{"text": "something here"}]], "resize_keyboard": True, } + +CHAT_PERMISSIONS = { + "can_send_messages": True, + "can_send_media_messages": True, + "can_send_polls": True, + "can_send_other_messages": True, + "can_add_web_page_previews": True, + "can_change_info": True, + "can_invite_users": True, + "can_pin_messages": True, +} + +CHAT_LOCATION = { + "location": LOCATION, + "address": "address", +} + +FULL_CHAT = { + **CHAT, + "photo": CHAT_PHOTO, + "bio": "bio", + "has_private_forwards": False, + "description": "description", + "invite_link": "invite_link", + "pinned_message": MESSAGE, + "permissions": CHAT_PERMISSIONS, + "slow_mode_delay": 10, + "message_auto_delete_time": 60, + "has_protected_content": True, + "sticker_set_name": "sticker_set_name", + "can_set_sticker_set": True, + "linked_chat_id": -1234567890, + "location": CHAT_LOCATION, +} diff --git a/tests/types/test_chat.py b/tests/types/test_chat.py index 1caa228d..c8e20146 100644 --- a/tests/types/test_chat.py +++ b/tests/types/test_chat.py @@ -1,5 +1,10 @@ -from aiogram import types -from .dataset import CHAT +import pytest + +from aiogram import Bot, types +from .dataset import CHAT, FULL_CHAT +from .. import FakeTelegram + +pytestmark = pytest.mark.asyncio chat = types.Chat(**CHAT) @@ -59,3 +64,10 @@ def test_chat_actions(): assert types.ChatActions.FIND_LOCATION == 'find_location' assert types.ChatActions.RECORD_VIDEO_NOTE == 'record_video_note' assert types.ChatActions.UPLOAD_VIDEO_NOTE == 'upload_video_note' + + +async def test_update_chat(bot: Bot): + Bot.set_current(bot) + async with FakeTelegram(message_data=FULL_CHAT): + await chat.update_chat() + assert chat.to_python() == types.Chat(**FULL_CHAT).to_python()