mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Update tests for all methods
This commit is contained in:
parent
33c661d732
commit
23abe35212
27 changed files with 428 additions and 189 deletions
|
|
@ -4,7 +4,7 @@ import abc
|
||||||
import secrets
|
import secrets
|
||||||
from typing import TYPE_CHECKING, Any, Dict, Generic, Optional, Type, TypeVar
|
from typing import TYPE_CHECKING, Any, Dict, Generic, Optional, Type, TypeVar
|
||||||
|
|
||||||
from pydantic import BaseConfig, BaseModel
|
from pydantic import BaseConfig, BaseModel, Extra
|
||||||
from pydantic.generics import GenericModel
|
from pydantic.generics import GenericModel
|
||||||
|
|
||||||
from ..types import InputFile, ResponseParameters
|
from ..types import InputFile, ResponseParameters
|
||||||
|
|
@ -35,7 +35,7 @@ class Response(ResponseParameters, GenericModel, Generic[T]):
|
||||||
class TelegramMethod(abc.ABC, BaseModel, Generic[T]):
|
class TelegramMethod(abc.ABC, BaseModel, Generic[T]):
|
||||||
class Config(BaseConfig):
|
class Config(BaseConfig):
|
||||||
# use_enum_values = True
|
# use_enum_values = True
|
||||||
# extra = Extra.allow
|
extra = Extra.allow
|
||||||
allow_population_by_field_name = True
|
allow_population_by_field_name = True
|
||||||
arbitrary_types_allowed = True
|
arbitrary_types_allowed = True
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,8 @@ class SendMediaGroup(TelegramMethod[List[Message]]):
|
||||||
|
|
||||||
return Request(method="sendMediaGroup", data=data, files=files)
|
return Request(method="sendMediaGroup", data=data, files=files)
|
||||||
|
|
||||||
def prepare_input_media(self, data: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
@staticmethod
|
||||||
if not self.media:
|
def prepare_input_media(data: Dict[str, Any], files: Dict[str, InputFile]) -> None:
|
||||||
return
|
|
||||||
for input_media in data.get("media", []): # type: Dict[str, Union[str, InputFile]]
|
for input_media in data.get("media", []): # type: Dict[str, Union[str, InputFile]]
|
||||||
if (
|
if (
|
||||||
"media" in input_media
|
"media" in input_media
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import EditMessageMedia, Request
|
from aiogram.api.methods import EditMessageMedia, Request
|
||||||
from aiogram.api.types import InputMedia, Message
|
from aiogram.api.types import BufferedInputFile, InputMedia, InputMediaPhoto, Message
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -12,7 +11,9 @@ class TestEditMessageMedia:
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(EditMessageMedia, ok=True, result=True)
|
prepare_result = bot.add_result_for(EditMessageMedia, ok=True, result=True)
|
||||||
|
|
||||||
response: Union[Message, bool] = await EditMessageMedia(media=InputMedia())
|
response: Union[Message, bool] = await EditMessageMedia(
|
||||||
|
media=InputMediaPhoto(media=BufferedInputFile(b"", "photo.png"))
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "editMessageMedia"
|
assert request.method == "editMessageMedia"
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
@ -21,7 +22,9 @@ class TestEditMessageMedia:
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(EditMessageMedia, ok=True, result=True)
|
prepare_result = bot.add_result_for(EditMessageMedia, ok=True, result=True)
|
||||||
|
|
||||||
response: Union[Message, bool] = await bot.edit_message_media(media=InputMedia())
|
response: Union[Message, bool] = await bot.edit_message_media(
|
||||||
|
media=InputMediaPhoto(media=BufferedInputFile(b"", "photo.png"))
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "editMessageMedia"
|
assert request.method == "editMessageMedia"
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ from aiogram.api.types import PhotoSize, UserProfilePhotos
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestGetUserProfilePhotos:
|
class TestGetUserProfilePhotos:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,85 @@
|
||||||
|
import datetime
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SendMediaGroup
|
from aiogram.api.methods import Request, SendMediaGroup
|
||||||
from aiogram.api.types import Message, InputMediaPhoto
|
from aiogram.api.types import (
|
||||||
|
BufferedInputFile,
|
||||||
|
Chat,
|
||||||
|
InputMediaPhoto,
|
||||||
|
InputMediaVideo,
|
||||||
|
Message,
|
||||||
|
PhotoSize,
|
||||||
|
Video,
|
||||||
|
)
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendMediaGroup:
|
class TestSendMediaGroup:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendMediaGroup, ok=True, result=...)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendMediaGroup,
|
||||||
|
ok=True,
|
||||||
|
result=[
|
||||||
|
Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||||
|
media_group_id="media group",
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
Message(
|
||||||
|
message_id=43,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||||
|
media_group_id="media group",
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
response: List[Message] = await SendMediaGroup(
|
response: List[Message] = await SendMediaGroup(
|
||||||
chat_id=42, media=[InputMediaPhoto(media="file id")]
|
chat_id=42,
|
||||||
|
media=[
|
||||||
|
InputMediaPhoto(media="file id"),
|
||||||
|
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendMediaGroup"
|
assert request.method == "sendMediaGroup"
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
#
|
@pytest.mark.asyncio
|
||||||
# @pytest.mark.asyncio
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
# async def test_bot_method(self, bot: MockedBot):
|
prepare_result = bot.add_result_for(
|
||||||
# prepare_result = bot.add_result_for(SendMediaGroup, ok=True, result=None)
|
SendMediaGroup,
|
||||||
#
|
ok=True,
|
||||||
# response: List[Message] = await bot.send_media_group(chat_id=..., media=...)
|
result=[
|
||||||
# request: Request = bot.get_request()
|
Message(
|
||||||
# assert request.method == "sendMediaGroup"
|
message_id=42,
|
||||||
# assert response == prepare_result.result
|
date=datetime.datetime.now(),
|
||||||
|
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||||
|
media_group_id="media group",
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
Message(
|
||||||
|
message_id=43,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||||
|
media_group_id="media group",
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
response: List[Message] = await bot.send_media_group(
|
||||||
|
chat_id=42,
|
||||||
|
media=[
|
||||||
|
InputMediaPhoto(media="file id"),
|
||||||
|
InputMediaVideo(media=BufferedInputFile(b"", "video.mp4")),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
request: Request = bot.get_request()
|
||||||
|
assert request.method == "sendMediaGroup"
|
||||||
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,45 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SendMessage
|
from aiogram.api.methods import Request, SendMessage
|
||||||
|
from aiogram.api.types import Chat, Message
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendMessage:
|
class TestSendMessage:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendMessage, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendMessage,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
text="test",
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendMessage(chat_id=..., text=...)
|
response: Message = await SendMessage(chat_id=42, text="test")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendMessage"
|
assert request.method == "sendMessage"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendMessage, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendMessage,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
text="test",
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_message(chat_id=..., text=...)
|
response: Message = await bot.send_message(chat_id=42, text="test")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendMessage"
|
assert request.method == "sendMessage"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,45 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SendPhoto
|
from aiogram.api.methods import Request, SendPhoto
|
||||||
|
from aiogram.api.types import Chat, Message, PhotoSize
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendPhoto:
|
class TestSendPhoto:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendPhoto, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendPhoto,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendPhoto(chat_id=..., photo=...)
|
response: Message = await SendPhoto(chat_id=42, photo="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendPhoto"
|
assert request.method == "sendPhoto"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendPhoto, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendPhoto,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
photo=[PhotoSize(file_id="file id", width=42, height=42)],
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_photo(chat_id=..., photo=...)
|
response: Message = await bot.send_photo(chat_id=42, photo="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendPhoto"
|
assert request.method == "sendPhoto"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,61 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SendPoll
|
from aiogram.api.methods import Request, SendPoll
|
||||||
|
from aiogram.api.types import Chat, Message, Poll, PollOption
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendPoll:
|
class TestSendPoll:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendPoll, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendPoll,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
poll=Poll(
|
||||||
|
id="QA",
|
||||||
|
question="Q",
|
||||||
|
options=[
|
||||||
|
PollOption(text="A", voter_count=0),
|
||||||
|
PollOption(text="B", voter_count=0),
|
||||||
|
],
|
||||||
|
is_closed=False,
|
||||||
|
),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendPoll(chat_id=..., question=..., options=...)
|
response: Message = await SendPoll(chat_id=42, question="Q?", options=["A", "B"])
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendPoll"
|
assert request.method == "sendPoll"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendPoll, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendPoll,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
poll=Poll(
|
||||||
|
id="QA",
|
||||||
|
question="Q",
|
||||||
|
options=[
|
||||||
|
PollOption(text="A", voter_count=0),
|
||||||
|
PollOption(text="B", voter_count=0),
|
||||||
|
],
|
||||||
|
is_closed=False,
|
||||||
|
),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_poll(chat_id=..., question=..., options=...)
|
response: Message = await bot.send_poll(chat_id=42, question="Q?", options=["A", "B"])
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendPoll"
|
assert request.method == "sendPoll"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,45 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SendSticker
|
from aiogram.api.methods import Request, SendSticker
|
||||||
|
from aiogram.api.types import Chat, Message, Sticker
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendSticker:
|
class TestSendSticker:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendSticker, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendSticker,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
sticker=Sticker(file_id="file id", width=42, height=42, is_animated=False),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendSticker(chat_id=..., sticker=...)
|
response: Message = await SendSticker(chat_id=42, sticker="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendSticker"
|
assert request.method == "sendSticker"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendSticker, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendSticker,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
sticker=Sticker(file_id="file id", width=42, height=42, is_animated=False),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_sticker(chat_id=..., sticker=...)
|
response: Message = await bot.send_sticker(chat_id=42, sticker="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendSticker"
|
assert request.method == "sendSticker"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,69 @@
|
||||||
|
import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SendVenue
|
from aiogram.api.methods import Request, SendVenue
|
||||||
|
from aiogram.api.types import Chat, Location, Message, Venue
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendVenue:
|
class TestSendVenue:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVenue, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVenue,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
venue=Venue(
|
||||||
|
location=Location(latitude=3.14, longitude=3.14),
|
||||||
|
title="Cupboard Under the Stairs",
|
||||||
|
address="Under the stairs, 4 Privet Drive, "
|
||||||
|
"Little Whinging, Surrey, England, Great Britain",
|
||||||
|
),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendVenue(
|
response: Message = await SendVenue(
|
||||||
chat_id=..., latitude=..., longitude=..., title=..., address=...
|
chat_id=42,
|
||||||
|
latitude=3.14,
|
||||||
|
longitude=3.14,
|
||||||
|
title="Cupboard Under the Stairs",
|
||||||
|
address="Under the stairs, 4 Privet Drive, "
|
||||||
|
"Little Whinging, Surrey, England, Great Britain",
|
||||||
)
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVenue"
|
assert request.method == "sendVenue"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVenue, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVenue,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
venue=Venue(
|
||||||
|
location=Location(latitude=3.14, longitude=3.14),
|
||||||
|
title="Cupboard Under the Stairs",
|
||||||
|
address="Under the stairs, 4 Privet Drive, "
|
||||||
|
"Little Whinging, Surrey, England, Great Britain",
|
||||||
|
),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_venue(
|
response: Message = await bot.send_venue(
|
||||||
chat_id=..., latitude=..., longitude=..., title=..., address=...
|
chat_id=42,
|
||||||
|
latitude=3.14,
|
||||||
|
longitude=3.14,
|
||||||
|
title="Cupboard Under the Stairs",
|
||||||
|
address="Under the stairs, 4 Privet Drive, "
|
||||||
|
"Little Whinging, Surrey, England, Great Britain",
|
||||||
)
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVenue"
|
assert request.method == "sendVenue"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,44 @@
|
||||||
import pytest
|
import datetime
|
||||||
|
|
||||||
|
import pytest
|
||||||
from aiogram.api.methods import Request, SendVideo
|
from aiogram.api.methods import Request, SendVideo
|
||||||
|
from aiogram.api.types import Chat, Message, Video
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendVideo:
|
class TestSendVideo:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVideo, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVideo,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendVideo(chat_id=..., video=...)
|
response: Message = await SendVideo(chat_id=42, video="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVideo"
|
assert request.method == "sendVideo"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVideo, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVideo,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
video=Video(file_id="file id", width=42, height=42, duration=0),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_video(chat_id=..., video=...)
|
response: Message = await bot.send_video(chat_id=42, video="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVideo"
|
assert request.method == "sendVideo"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,48 @@
|
||||||
import pytest
|
import datetime
|
||||||
|
|
||||||
|
import pytest
|
||||||
from aiogram.api.methods import Request, SendVideoNote
|
from aiogram.api.methods import Request, SendVideoNote
|
||||||
|
from aiogram.api.types import BufferedInputFile, Chat, Message, VideoNote
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendVideoNote:
|
class TestSendVideoNote:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVideoNote, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVideoNote,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
video_note=VideoNote(file_id="file id", length=0, duration=0),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendVideoNote(chat_id=..., video_note=...)
|
response: Message = await SendVideoNote(
|
||||||
|
chat_id=42, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVideoNote"
|
assert request.method == "sendVideoNote"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVideoNote, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVideoNote,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
video_note=VideoNote(file_id="file id", length=0, duration=0),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_video_note(chat_id=..., video_note=...)
|
response: Message = await bot.send_video_note(
|
||||||
|
chat_id=42, video_note="file id", thumb=BufferedInputFile(b"", "file.png")
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVideoNote"
|
assert request.method == "sendVideoNote"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,44 @@
|
||||||
import pytest
|
import datetime
|
||||||
|
|
||||||
|
import pytest
|
||||||
from aiogram.api.methods import Request, SendVoice
|
from aiogram.api.methods import Request, SendVoice
|
||||||
|
from aiogram.api.types import Chat, Message, Voice
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSendVoice:
|
class TestSendVoice:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVoice, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVoice,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
voice=Voice(file_id="file id", duration=0),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await SendVoice(chat_id=..., voice=...)
|
response: Message = await SendVoice(chat_id=42, voice="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVoice"
|
assert request.method == "sendVoice"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SendVoice, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
SendVoice,
|
||||||
|
ok=True,
|
||||||
|
result=Message(
|
||||||
|
message_id=42,
|
||||||
|
date=datetime.datetime.now(),
|
||||||
|
voice=Voice(file_id="file id", duration=0),
|
||||||
|
chat=Chat(id=42, type="private"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Message = await bot.send_voice(chat_id=..., voice=...)
|
response: Message = await bot.send_voice(chat_id=42, voice="file id")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "sendVoice"
|
assert request.method == "sendVoice"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,21 @@ from aiogram.api.methods import Request, SetChatDescription
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetChatDescription:
|
class TestSetChatDescription:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatDescription, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatDescription, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetChatDescription(chat_id=...)
|
response: bool = await SetChatDescription(chat_id=-42, description='awesome chat')
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatDescription"
|
assert request.method == "setChatDescription"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatDescription, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatDescription, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_chat_description(chat_id=...)
|
response: bool = await bot.set_chat_description(chat_id=-42, description='awesome chat')
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatDescription"
|
assert request.method == "setChatDescription"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,28 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SetChatPermissions
|
from aiogram.api.methods import Request, SetChatPermissions
|
||||||
|
from aiogram.api.types import ChatPermissions
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetChatPermissions:
|
class TestSetChatPermissions:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatPermissions, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatPermissions, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetChatPermissions(chat_id=..., permissions=...)
|
response: bool = await SetChatPermissions(
|
||||||
|
chat_id=-42, permissions=ChatPermissions(can_send_messages=False)
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatPermissions"
|
assert request.method == "setChatPermissions"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatPermissions, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatPermissions, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_chat_permissions(chat_id=..., permissions=...)
|
response: bool = await bot.set_chat_permissions(
|
||||||
|
chat_id=-42, permissions=ChatPermissions(can_send_messages=False)
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatPermissions"
|
assert request.method == "setChatPermissions"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,28 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SetChatPhoto
|
from aiogram.api.methods import Request, SetChatPhoto
|
||||||
|
from aiogram.api.types import BufferedInputFile, InputFile
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetChatPhoto:
|
class TestSetChatPhoto:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatPhoto, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatPhoto, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetChatPhoto(chat_id=..., photo=...)
|
response: bool = await SetChatPhoto(
|
||||||
|
chat_id=-42, photo=BufferedInputFile(b"", filename="file.png")
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatPhoto"
|
assert request.method == "setChatPhoto"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatPhoto, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatPhoto, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_chat_photo(chat_id=..., photo=...)
|
response: bool = await bot.set_chat_photo(
|
||||||
|
chat_id=-42, photo=BufferedInputFile(b"", filename="file.png")
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatPhoto"
|
assert request.method == "setChatPhoto"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,23 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SetChatStickerSet
|
from aiogram.api.methods import Request, SetChatStickerSet
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetChatStickerSet:
|
class TestSetChatStickerSet:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatStickerSet, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatStickerSet, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetChatStickerSet(chat_id=..., sticker_set_name=...)
|
response: bool = await SetChatStickerSet(chat_id=-42, sticker_set_name="test")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatStickerSet"
|
assert request.method == "setChatStickerSet"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatStickerSet, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatStickerSet, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_chat_sticker_set(chat_id=..., sticker_set_name=...)
|
response: bool = await bot.set_chat_sticker_set(chat_id=-42, sticker_set_name="test")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatStickerSet"
|
assert request.method == "setChatStickerSet"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,21 @@ from aiogram.api.methods import Request, SetChatTitle
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetChatTitle:
|
class TestSetChatTitle:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatTitle, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatTitle, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetChatTitle(chat_id=..., title=...)
|
response: bool = await SetChatTitle(chat_id=-42, title='test chat')
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatTitle"
|
assert request.method == "setChatTitle"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetChatTitle, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetChatTitle, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_chat_title(chat_id=..., title=...)
|
response: bool = await bot.set_chat_title(chat_id=-42, title='test chat')
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setChatTitle"
|
assert request.method == "setChatTitle"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,30 @@
|
||||||
import pytest
|
from typing import Union
|
||||||
|
|
||||||
|
import pytest
|
||||||
from aiogram.api.methods import Request, SetGameScore
|
from aiogram.api.methods import Request, SetGameScore
|
||||||
|
from aiogram.api.types import Message
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetGameScore:
|
class TestSetGameScore:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetGameScore, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetGameScore, ok=True, result=True)
|
||||||
|
|
||||||
response: Union[Message, bool] = await SetGameScore(user_id=..., score=...)
|
response: Union[Message, bool] = await SetGameScore(
|
||||||
|
user_id=42, score=100500, inline_message_id="inline message"
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setGameScore"
|
assert request.method == "setGameScore"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetGameScore, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetGameScore, ok=True, result=True)
|
||||||
|
|
||||||
response: Union[Message, bool] = await bot.set_game_score(user_id=..., score=...)
|
response: Union[Message, bool] = await bot.set_game_score(
|
||||||
|
user_id=42, score=100500, inline_message_id="inline message"
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setGameScore"
|
assert request.method == "setGameScore"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,25 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SetPassportDataErrors
|
from aiogram.api.methods import Request, SetPassportDataErrors
|
||||||
|
from aiogram.api.types import PassportElementError
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetPassportDataErrors:
|
class TestSetPassportDataErrors:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetPassportDataErrors, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetPassportDataErrors, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetPassportDataErrors(user_id=..., errors=...)
|
response: bool = await SetPassportDataErrors(user_id=42, errors=[PassportElementError()])
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setPassportDataErrors"
|
assert request.method == "setPassportDataErrors"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetPassportDataErrors, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetPassportDataErrors, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_passport_data_errors(user_id=..., errors=...)
|
response: bool = await bot.set_passport_data_errors(user_id=42, errors=[PassportElementError()])
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setPassportDataErrors"
|
assert request.method == "setPassportDataErrors"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,21 @@ from aiogram.api.methods import Request, SetStickerPositionInSet
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetStickerPositionInSet:
|
class TestSetStickerPositionInSet:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetStickerPositionInSet, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetStickerPositionInSet, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetStickerPositionInSet(sticker=..., position=...)
|
response: bool = await SetStickerPositionInSet(sticker='sticker', position=42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setStickerPositionInSet"
|
assert request.method == "setStickerPositionInSet"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetStickerPositionInSet, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetStickerPositionInSet, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_sticker_position_in_set(sticker=..., position=...)
|
response: bool = await bot.set_sticker_position_in_set(sticker='sticker', position=42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setStickerPositionInSet"
|
assert request.method == "setStickerPositionInSet"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,23 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, SetWebhook
|
from aiogram.api.methods import Request, SetWebhook
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestSetWebhook:
|
class TestSetWebhook:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetWebhook, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetWebhook, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await SetWebhook(url=...)
|
response: bool = await SetWebhook(url="https://example.com")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setWebhook"
|
assert request.method == "setWebhook"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(SetWebhook, ok=True, result=None)
|
prepare_result = bot.add_result_for(SetWebhook, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.set_webhook(url=...)
|
response: bool = await bot.set_webhook(url="https://example.com")
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "setWebhook"
|
assert request.method == "setWebhook"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,30 @@
|
||||||
import pytest
|
from typing import Union
|
||||||
|
|
||||||
|
import pytest
|
||||||
from aiogram.api.methods import Request, StopMessageLiveLocation
|
from aiogram.api.methods import Request, StopMessageLiveLocation
|
||||||
|
from aiogram.api.types import Message
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestStopMessageLiveLocation:
|
class TestStopMessageLiveLocation:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(StopMessageLiveLocation, ok=True, result=None)
|
prepare_result = bot.add_result_for(StopMessageLiveLocation, ok=True, result=True)
|
||||||
|
|
||||||
response: Union[Message, bool] = await StopMessageLiveLocation()
|
response: Union[Message, bool] = await StopMessageLiveLocation(
|
||||||
|
inline_message_id="inline message id"
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "stopMessageLiveLocation"
|
assert request.method == "stopMessageLiveLocation"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(StopMessageLiveLocation, ok=True, result=None)
|
prepare_result = bot.add_result_for(StopMessageLiveLocation, ok=True, result=True)
|
||||||
|
|
||||||
response: Union[Message, bool] = await bot.stop_message_live_location()
|
response: Union[Message, bool] = await bot.stop_message_live_location(
|
||||||
|
inline_message_id="inline message id"
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "stopMessageLiveLocation"
|
assert request.method == "stopMessageLiveLocation"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,42 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, StopPoll
|
from aiogram.api.methods import Request, StopPoll
|
||||||
|
from aiogram.api.types import Poll, PollOption
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestStopPoll:
|
class TestStopPoll:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(StopPoll, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
StopPoll,
|
||||||
|
ok=True,
|
||||||
|
result=Poll(
|
||||||
|
id="QA",
|
||||||
|
question="Q",
|
||||||
|
options=[PollOption(text="A", voter_count=0), PollOption(text="B", voter_count=0)],
|
||||||
|
is_closed=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Poll = await StopPoll(chat_id=..., message_id=...)
|
response: Poll = await StopPoll(chat_id=42, message_id=42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "stopPoll"
|
assert request.method == "stopPoll"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(StopPoll, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
StopPoll,
|
||||||
|
ok=True,
|
||||||
|
result=Poll(
|
||||||
|
id="QA",
|
||||||
|
question="Q",
|
||||||
|
options=[PollOption(text="A", voter_count=0), PollOption(text="B", voter_count=0)],
|
||||||
|
is_closed=False,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
response: Poll = await bot.stop_poll(chat_id=..., message_id=...)
|
response: Poll = await bot.stop_poll(chat_id=42, message_id=42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "stopPoll"
|
assert request.method == "stopPoll"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,21 @@ from aiogram.api.methods import Request, UnbanChatMember
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestUnbanChatMember:
|
class TestUnbanChatMember:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(UnbanChatMember, ok=True, result=None)
|
prepare_result = bot.add_result_for(UnbanChatMember, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await UnbanChatMember(chat_id=..., user_id=...)
|
response: bool = await UnbanChatMember(chat_id=-42, user_id=42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "unbanChatMember"
|
assert request.method == "unbanChatMember"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(UnbanChatMember, ok=True, result=None)
|
prepare_result = bot.add_result_for(UnbanChatMember, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.unban_chat_member(chat_id=..., user_id=...)
|
response: bool = await bot.unban_chat_member(chat_id=-42, user_id=42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "unbanChatMember"
|
assert request.method == "unbanChatMember"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,21 @@ from aiogram.api.methods import Request, UnpinChatMessage
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestUnpinChatMessage:
|
class TestUnpinChatMessage:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(UnpinChatMessage, ok=True, result=None)
|
prepare_result = bot.add_result_for(UnpinChatMessage, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await UnpinChatMessage(chat_id=...)
|
response: bool = await UnpinChatMessage(chat_id=-42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "unpinChatMessage"
|
assert request.method == "unpinChatMessage"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(UnpinChatMessage, ok=True, result=None)
|
prepare_result = bot.add_result_for(UnpinChatMessage, ok=True, result=True)
|
||||||
|
|
||||||
response: bool = await bot.unpin_chat_message(chat_id=...)
|
response: bool = await bot.unpin_chat_message(chat_id=-42)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "unpinChatMessage"
|
assert request.method == "unpinChatMessage"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,32 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from aiogram.api.methods import Request, UploadStickerFile
|
from aiogram.api.methods import Request, UploadStickerFile
|
||||||
|
from aiogram.api.types import BufferedInputFile, File
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip
|
|
||||||
class TestUploadStickerFile:
|
class TestUploadStickerFile:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_method(self, bot: MockedBot):
|
async def test_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(UploadStickerFile, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
UploadStickerFile, ok=True, result=File(file_id="file id")
|
||||||
|
)
|
||||||
|
|
||||||
response: File = await UploadStickerFile(user_id=..., png_sticker=...)
|
response: File = await UploadStickerFile(
|
||||||
|
user_id=42, png_sticker=BufferedInputFile(b"", "file.png")
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "uploadStickerFile"
|
assert request.method == "uploadStickerFile"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_bot_method(self, bot: MockedBot):
|
async def test_bot_method(self, bot: MockedBot):
|
||||||
prepare_result = bot.add_result_for(UploadStickerFile, ok=True, result=None)
|
prepare_result = bot.add_result_for(
|
||||||
|
UploadStickerFile, ok=True, result=File(file_id="file id")
|
||||||
|
)
|
||||||
|
|
||||||
response: File = await bot.upload_sticker_file(user_id=..., png_sticker=...)
|
response: File = await bot.upload_sticker_file(
|
||||||
|
user_id=42, png_sticker=BufferedInputFile(b"", "file.png")
|
||||||
|
)
|
||||||
request: Request = bot.get_request()
|
request: Request = bot.get_request()
|
||||||
assert request.method == "uploadStickerFile"
|
assert request.method == "uploadStickerFile"
|
||||||
# assert request.data == {}
|
|
||||||
assert response == prepare_result.result
|
assert response == prepare_result.result
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue