feat: ChatFactory and private_chat fixture

This commit is contained in:
Egor 2020-07-03 16:08:31 +05:00
parent 2cf2c2e98b
commit 3016c8e21e
18 changed files with 161 additions and 131 deletions

View file

@ -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(),
),
)

View file

@ -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 == {}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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

View file

@ -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",

View file

@ -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

View file

@ -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")),

View file

@ -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

View file

@ -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"

View file

@ -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(),
),
)

View file

@ -25,7 +25,6 @@ from aiogram.api.methods import (
from aiogram.api.types import (
Animation,
Audio,
Chat,
Contact,
Dice,
Document,
@ -45,6 +44,7 @@ from aiogram.api.types import (
Voice,
)
from aiogram.api.types.message import ContentType, Message
from tests.factories.chat import ChatFactory
from tests.factories.user import UserFactory
@ -57,7 +57,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
text="test",
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.TEXT,
@ -67,7 +67,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
audio=Audio(file_id="file id", file_unique_id="file id", duration=42),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.AUDIO,
@ -83,7 +83,7 @@ class TestMessage:
height=42,
duration=0,
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.ANIMATION,
@ -93,7 +93,7 @@ class TestMessage:
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=ChatFactory(),
from_user=UserFactory(),
),
ContentType.DOCUMENT,
@ -111,7 +111,7 @@ class TestMessage:
)
],
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.GAME,
@ -123,7 +123,7 @@ class TestMessage:
photo=[
PhotoSize(file_id="file id", file_unique_id="file id", width=42, height=42)
],
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.PHOTO,
@ -139,7 +139,7 @@ class TestMessage:
height=42,
is_animated=False,
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.STICKER,
@ -155,7 +155,7 @@ class TestMessage:
height=42,
duration=0,
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.VIDEO,
@ -167,7 +167,7 @@ class TestMessage:
video_note=VideoNote(
file_id="file id", file_unique_id="file id", length=0, duration=0
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.VIDEO_NOTE,
@ -177,7 +177,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
voice=Voice(file_id="file id", file_unique_id="file id", duration=0),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.VOICE,
@ -187,7 +187,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
contact=Contact(phone_number="911", first_name="911"),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.CONTACT,
@ -202,7 +202,7 @@ class TestMessage:
address="Under the stairs, 4 Privet Drive, "
"Little Whinging, Surrey, England, Great Britain",
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.VENUE,
@ -212,7 +212,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
location=Location(longitude=3.14, latitude=3.14),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.LOCATION,
@ -222,7 +222,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
new_chat_members=[UserFactory()],
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.NEW_CHAT_MEMBERS,
@ -232,7 +232,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
left_chat_member=UserFactory(),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.LEFT_CHAT_MEMBER,
@ -248,7 +248,7 @@ class TestMessage:
currency="BTC",
total_amount=1,
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.INVOICE,
@ -264,7 +264,7 @@ class TestMessage:
telegram_payment_charge_id="charge",
provider_payment_charge_id="payment",
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.SUCCESSFUL_PAYMENT,
@ -274,7 +274,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
connected_website="token",
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.CONNECTED_WEBSITE,
@ -284,7 +284,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
migrate_from_chat_id=42,
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.MIGRATE_FROM_CHAT_ID,
@ -294,7 +294,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
migrate_to_chat_id=42,
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.MIGRATE_TO_CHAT_ID,
@ -307,10 +307,10 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
text="pinned",
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.PINNED_MESSAGE,
@ -320,7 +320,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
new_chat_title="test",
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.NEW_CHAT_TITLE,
@ -332,7 +332,7 @@ class TestMessage:
new_chat_photo=[
PhotoSize(file_id="file id", file_unique_id="file id", width=42, height=42)
],
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.NEW_CHAT_PHOTO,
@ -342,7 +342,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
delete_chat_photo=True,
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.DELETE_CHAT_PHOTO,
@ -352,7 +352,7 @@ class TestMessage:
message_id=42,
date=datetime.datetime.now(),
group_chat_created=True,
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.GROUP_CHAT_CREATED,
@ -365,7 +365,7 @@ class TestMessage:
data=[],
credentials=EncryptedCredentials(data="test", hash="test", secret="test"),
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.PASSPORT_DATA,
@ -388,7 +388,7 @@ class TestMessage:
total_voter_count=0,
correct_option_id=1,
),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.POLL,
@ -397,7 +397,7 @@ class TestMessage:
Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
dice=Dice(value=6, emoji="X"),
from_user=UserFactory(),
),
@ -407,7 +407,7 @@ class TestMessage:
Message(
message_id=42,
date=datetime.datetime.now(),
chat=Chat(id=42, type="private"),
chat=ChatFactory(),
from_user=UserFactory(),
),
ContentType.UNKNOWN,
@ -485,7 +485,7 @@ class TestMessage:
],
):
message = Message(
message_id=42, chat=Chat(id=42, type="private"), date=datetime.datetime.now()
message_id=42, chat=ChatFactory(), date=datetime.datetime.now()
)
alias_name = "_".join(item for item in [alias_type, alias_for_method] if item)