mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 01:54:53 +00:00
More tests
This commit is contained in:
parent
635f08b88f
commit
33c661d732
5 changed files with 150 additions and 54 deletions
|
|
@ -1,27 +1,45 @@
|
|||
import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from aiogram.api.methods import Request, SendLocation
|
||||
from aiogram.api.types import Chat, Location, Message
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
@pytest.mark.skip
|
||||
class TestSendLocation:
|
||||
@pytest.mark.asyncio
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SendLocation, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(
|
||||
SendLocation,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
location=Location(longitude=3.14, latitude=3.14),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await SendLocation(chat_id=..., latitude=..., longitude=...)
|
||||
response: Message = await SendLocation(chat_id=42, latitude=3.14, longitude=3.14)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendLocation"
|
||||
# assert request.data == {}
|
||||
assert response == prepare_result.result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(SendLocation, ok=True, result=None)
|
||||
prepare_result = bot.add_result_for(
|
||||
SendLocation,
|
||||
ok=True,
|
||||
result=Message(
|
||||
message_id=42,
|
||||
date=datetime.datetime.now(),
|
||||
location=Location(longitude=3.14, latitude=3.14),
|
||||
chat=Chat(id=42, type="private"),
|
||||
),
|
||||
)
|
||||
|
||||
response: Message = await bot.send_location(chat_id=..., latitude=..., longitude=...)
|
||||
response: Message = await bot.send_location(chat_id=42, latitude=3.14, longitude=3.14)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "sendLocation"
|
||||
# assert request.data == {}
|
||||
assert response == prepare_result.result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue