mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
feat: ChatFactory and private_chat fixture
This commit is contained in:
parent
2cf2c2e98b
commit
3016c8e21e
18 changed files with 161 additions and 131 deletions
|
|
@ -4,7 +4,8 @@ from typing import Union
|
|||
import pytest
|
||||
|
||||
from aiogram.api.methods import EditMessageCaption, Request
|
||||
from aiogram.api.types import Chat, Message
|
||||
from aiogram.api.types import Message
|
||||
from tests.factories.chat import ChatFactory
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -15,10 +16,7 @@ class TestEditMessageCaption:
|
|||
EditMessageCaption,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
text="text",
|
||||
chat=Chat(id=42, type="private"),
|
||||
message_id=42, date=datetime.datetime.now(), text="text", chat=ChatFactory(),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -33,10 +31,7 @@ class TestEditMessageCaption:
|
|||
EditMessageCaption,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
text="text",
|
||||
chat=Chat(id=42, type="private"),
|
||||
message_id=42, date=datetime.datetime.now(), text="text", chat=ChatFactory(),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,38 +9,32 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestForwardMessage:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
ForwardMessage,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, title="chat", type="private"),
|
||||
text="text",
|
||||
),
|
||||
result=Message(message_id=42, date=datetime.datetime.now(), chat=private_chat, text="text", ),
|
||||
)
|
||||
|
||||
response: Message = await ForwardMessage(chat_id=42, from_chat_id=42, message_id=42)
|
||||
response: Message = await ForwardMessage(
|
||||
chat_id=private_chat.id, from_chat_id=private_chat.id, message_id=42
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "forwardMessage"
|
||||
# assert request.data == {}
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
ForwardMessage,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
chat=Chat(id=42, title="chat", type="private"),
|
||||
text="text",
|
||||
),
|
||||
result=Message(message_id=42, date=datetime.datetime.now(), chat=private_chat, text="text", ),
|
||||
)
|
||||
|
||||
response: Message = await bot.forward_message(chat_id=42, from_chat_id=42, message_id=42)
|
||||
response: Message = await bot.forward_message(
|
||||
chat_id=private_chat.id, from_chat_id=private_chat.id, message_id=42
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "forwardMessage"
|
||||
# assert request.data == {}
|
||||
|
|
|
|||
|
|
@ -2,28 +2,32 @@ import pytest
|
|||
|
||||
from aiogram.api.methods import GetChat, Request
|
||||
from aiogram.api.types import Chat
|
||||
from aiogram.api.types.chat import ChatType
|
||||
from tests.factories.chat import ChatFactory
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestGetChat:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
channel = ChatFactory(type=ChatType.CHANNEL)
|
||||
prepare_result = bot.add_result_for(
|
||||
GetChat, ok=True, result=Chat(id=-42, type="channel", title="chat")
|
||||
GetChat, ok=True, result=channel
|
||||
)
|
||||
|
||||
response: Chat = await GetChat(chat_id=-42)
|
||||
response: Chat = await GetChat(chat_id=channel.id)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "getChat"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
channel = ChatFactory(type=ChatType.CHANNEL)
|
||||
prepare_result = bot.add_result_for(
|
||||
GetChat, ok=True, result=Chat(id=-42, type="channel", title="chat")
|
||||
GetChat, ok=True, result=channel
|
||||
)
|
||||
|
||||
response: Chat = await bot.get_chat(chat_id=-42)
|
||||
response: Chat = await bot.get_chat(chat_id=channel.id)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "getChat"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendAnimation:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendAnimation,
|
||||
ok=True,
|
||||
|
|
@ -19,17 +19,17 @@ class TestSendAnimation:
|
|||
animation=Animation(
|
||||
file_id="file id", width=42, height=42, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendAnimation(chat_id=42, animation="file id")
|
||||
response: Message = await SendAnimation(chat_id=private_chat.id, animation="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendAnimation"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendAnimation,
|
||||
ok=True,
|
||||
|
|
@ -39,11 +39,11 @@ class TestSendAnimation:
|
|||
animation=Animation(
|
||||
file_id="file id", width=42, height=42, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_animation(chat_id=42, animation="file id")
|
||||
response: Message = await bot.send_animation(chat_id=private_chat.id, animation="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendAnimation"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ import datetime
|
|||
import pytest
|
||||
|
||||
from aiogram.api.methods import Request, SendAudio
|
||||
from aiogram.api.types import Audio, Chat, File, Message
|
||||
from aiogram.api.types import Audio, Chat, Message
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSendAudio:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendAudio,
|
||||
ok=True,
|
||||
|
|
@ -17,17 +17,17 @@ class TestSendAudio:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
audio=Audio(file_id="file id", duration=42, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendAudio(chat_id=42, audio="file id")
|
||||
response: Message = await SendAudio(chat_id=private_chat.id, audio="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendAudio"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendAudio,
|
||||
ok=True,
|
||||
|
|
@ -35,11 +35,11 @@ class TestSendAudio:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
audio=Audio(file_id="file id", duration=42, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_audio(chat_id=42, audio="file id")
|
||||
response: Message = await bot.send_audio(chat_id=private_chat.id, audio="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendAudio"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendContact:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendContact,
|
||||
ok=True,
|
||||
|
|
@ -17,17 +17,17 @@ class TestSendContact:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
contact=Contact(phone_number="911", first_name="911"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendContact(chat_id=42, phone_number="911", first_name="911")
|
||||
response: Message = await SendContact(chat_id=private_chat.id, phone_number="911", first_name="911")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendContact"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendContact,
|
||||
ok=True,
|
||||
|
|
@ -35,12 +35,12 @@ class TestSendContact:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
contact=Contact(phone_number="911", first_name="911"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_contact(
|
||||
chat_id=42, phone_number="911", first_name="911"
|
||||
chat_id=private_chat.id, phone_number="911", first_name="911"
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendContact"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendDocument:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendDocument,
|
||||
ok=True,
|
||||
|
|
@ -17,17 +17,17 @@ class TestSendDocument:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
document=Document(file_id="file id", file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendDocument(chat_id=42, document="file id")
|
||||
response: Message = await SendDocument(chat_id=private_chat.id, document="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendDocument"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendDocument,
|
||||
ok=True,
|
||||
|
|
@ -35,11 +35,11 @@ class TestSendDocument:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
document=Document(file_id="file id", file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_document(chat_id=42, document="file id")
|
||||
response: Message = await bot.send_document(chat_id=private_chat.id, document="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendDocument"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendGame:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendGame,
|
||||
ok=True,
|
||||
|
|
@ -23,17 +23,17 @@ class TestSendGame:
|
|||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendGame(chat_id=42, game_short_name="game")
|
||||
response: Message = await SendGame(chat_id=private_chat.id, game_short_name="game")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendGame"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendGame,
|
||||
ok=True,
|
||||
|
|
@ -47,11 +47,11 @@ class TestSendGame:
|
|||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_game(chat_id=42, game_short_name="game")
|
||||
response: Message = await bot.send_game(chat_id=private_chat.id, game_short_name="game")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendGame"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -4,12 +4,13 @@ import pytest
|
|||
|
||||
from aiogram.api.methods import Request, SendInvoice
|
||||
from aiogram.api.types import Chat, Invoice, LabeledPrice, Message
|
||||
from tests.factories.chat import ChatFactory
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSendInvoice:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendInvoice,
|
||||
ok=True,
|
||||
|
|
@ -23,12 +24,12 @@ class TestSendInvoice:
|
|||
currency="BTC",
|
||||
total_amount=1,
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendInvoice(
|
||||
chat_id=42,
|
||||
chat_id=private_chat.id,
|
||||
title="test",
|
||||
description="test",
|
||||
payload="payload",
|
||||
|
|
@ -42,7 +43,7 @@ class TestSendInvoice:
|
|||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendInvoice,
|
||||
ok=True,
|
||||
|
|
@ -56,12 +57,12 @@ class TestSendInvoice:
|
|||
currency="BTC",
|
||||
total_amount=1,
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_invoice(
|
||||
chat_id=42,
|
||||
chat_id=private_chat.id,
|
||||
title="test",
|
||||
description="test",
|
||||
payload="payload",
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendLocation:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendLocation,
|
||||
ok=True,
|
||||
|
|
@ -17,17 +17,17 @@ class TestSendLocation:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
location=Location(longitude=3.14, latitude=3.14),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendLocation(chat_id=42, latitude=3.14, longitude=3.14)
|
||||
response: Message = await SendLocation(chat_id=private_chat.id, latitude=3.14, longitude=3.14)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendLocation"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendLocation,
|
||||
ok=True,
|
||||
|
|
@ -35,11 +35,11 @@ class TestSendLocation:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
location=Location(longitude=3.14, latitude=3.14),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_location(chat_id=42, latitude=3.14, longitude=3.14)
|
||||
response: Message = await bot.send_location(chat_id=private_chat.id, latitude=3.14, longitude=3.14)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendLocation"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendMediaGroup:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendMediaGroup,
|
||||
ok=True,
|
||||
|
|
@ -30,7 +30,7 @@ class TestSendMediaGroup:
|
|||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
Message(
|
||||
message_id=43,
|
||||
|
|
@ -43,13 +43,13 @@ class TestSendMediaGroup:
|
|||
file_unique_id="file id",
|
||||
),
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
response: List[Message] = await SendMediaGroup(
|
||||
chat_id=42,
|
||||
chat_id=private_chat.id,
|
||||
media=[
|
||||
InputMediaPhoto(media="file id"),
|
||||
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
|
||||
|
|
@ -60,7 +60,7 @@ class TestSendMediaGroup:
|
|||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendMediaGroup,
|
||||
ok=True,
|
||||
|
|
@ -72,7 +72,7 @@ class TestSendMediaGroup:
|
|||
PhotoSize(file_id="file id", width=42, height=42, file_unique_id="file id")
|
||||
],
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
Message(
|
||||
message_id=43,
|
||||
|
|
@ -85,13 +85,13 @@ class TestSendMediaGroup:
|
|||
file_unique_id="file id",
|
||||
),
|
||||
media_group_id="media group",
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
response: List[Message] = await bot.send_media_group(
|
||||
chat_id=42,
|
||||
chat_id=private_chat.id,
|
||||
media=[
|
||||
InputMediaPhoto(media="file id"),
|
||||
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendSticker:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendSticker,
|
||||
ok=True,
|
||||
|
|
@ -23,17 +23,17 @@ class TestSendSticker:
|
|||
is_animated=False,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendSticker(chat_id=42, sticker="file id")
|
||||
response: Message = await SendSticker(chat_id=private_chat.id, sticker="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendSticker"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendSticker,
|
||||
ok=True,
|
||||
|
|
@ -47,11 +47,11 @@ class TestSendSticker:
|
|||
is_animated=False,
|
||||
file_unique_id="file id",
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_sticker(chat_id=42, sticker="file id")
|
||||
response: Message = await bot.send_sticker(chat_id=private_chat.id, sticker="file id")
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendSticker"
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
class TestSendVideoNote:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
async def test_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendVideoNote,
|
||||
ok=True,
|
||||
|
|
@ -19,19 +19,19 @@ class TestSendVideoNote:
|
|||
video_note=VideoNote(
|
||||
file_id="file id", length=0, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendVideoNote(
|
||||
chat_id=42, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||
chat_id=private_chat.id, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendVideoNote"
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
async def test_bot_method(self, bot: MockedBot, private_chat: Chat):
|
||||
prepare_result = bot.add_result_for(
|
||||
SendVideoNote,
|
||||
ok=True,
|
||||
|
|
@ -41,12 +41,12 @@ class TestSendVideoNote:
|
|||
video_note=VideoNote(
|
||||
file_id="file id", length=0, duration=0, file_unique_id="file id"
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat,
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_video_note(
|
||||
chat_id=42, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||
chat_id=private_chat.id, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendVideoNote"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import datetime
|
|||
import pytest
|
||||
|
||||
from aiogram.api.methods import Request, SendVoice
|
||||
from aiogram.api.types import Chat, Message, Voice
|
||||
from aiogram.api.types import Message, Voice
|
||||
from tests.factories.chat import ChatFactory
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ class TestSendVoice:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
voice=Voice(file_id="file id", duration=0, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=ChatFactory(),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ class TestSendVoice:
|
|||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
voice=Voice(file_id="file id", duration=0, file_unique_id="file id"),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=ChatFactory(),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue