mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
refator: use MessageFactory instead of Message, just a part
This commit is contained in:
parent
e883366dc6
commit
0e005f661c
15 changed files with 54 additions and 143 deletions
|
|
@ -4,18 +4,18 @@ import pytest
|
|||
|
||||
from aiogram.api.methods import Request, SendPoll
|
||||
from aiogram.api.types import Chat, Message, Poll, PollOption
|
||||
from tests.conftest import private_chat
|
||||
from tests.factories.message import MessageFactory
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
class TestSendPoll:
|
||||
@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(
|
||||
SendPoll,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
result=MessageFactory(
|
||||
poll=Poll(
|
||||
id="QA",
|
||||
question="Q",
|
||||
|
|
@ -30,25 +30,23 @@ class TestSendPoll:
|
|||
total_voter_count=0,
|
||||
correct_option_id=0,
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendPoll(
|
||||
chat_id=42, question="Q?", options=["A", "B"], correct_option_id=0, type="quiz"
|
||||
chat_id=private_chat.id, question="Q?", options=["A", "B"], correct_option_id=0, type="quiz"
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendPoll"
|
||||
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(
|
||||
SendPoll,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
result=MessageFactory(
|
||||
poll=Poll(
|
||||
id="QA",
|
||||
question="Q",
|
||||
|
|
@ -63,12 +61,12 @@ class TestSendPoll:
|
|||
total_voter_count=0,
|
||||
correct_option_id=0,
|
||||
),
|
||||
chat=Chat(id=42, type="private"),
|
||||
chat=private_chat
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_poll(
|
||||
chat_id=42, question="Q?", options=["A", "B"], correct_option_id=0, type="quiz"
|
||||
chat_id=private_chat.id, question="Q?", options=["A", "B"], correct_option_id=0, type="quiz"
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendPoll"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue