mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
Update default parse_mode propagation.
This commit is contained in:
parent
4d631a3069
commit
f5684aef07
80 changed files with 552 additions and 185 deletions
|
|
@ -42,12 +42,13 @@ class TestBot:
|
|||
new_callable=CoroutineMock,
|
||||
) as mocked_make_request:
|
||||
await bot(method)
|
||||
mocked_make_request.assert_awaited_with("42:TEST", method)
|
||||
mocked_make_request.assert_awaited_with(bot, method, timeout=None)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_close(self):
|
||||
bot = Bot("42:TEST", session=AiohttpSession())
|
||||
await bot.session.create_session()
|
||||
session = AiohttpSession()
|
||||
bot = Bot("42:TEST", session=session)
|
||||
await session.create_session()
|
||||
|
||||
with patch(
|
||||
"aiogram.api.client.session.aiohttp.AiohttpSession.close", new_callable=CoroutineMock
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@ import aiohttp_socks
|
|||
import pytest
|
||||
from aresponses import ResponsesMockServer
|
||||
|
||||
from aiogram import Bot
|
||||
from aiogram.api.client.session.aiohttp import AiohttpSession
|
||||
from aiogram.api.methods import Request, TelegramMethod
|
||||
from aiogram.api.types import InputFile
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
try:
|
||||
from asynctest import CoroutineMock, patch
|
||||
|
|
@ -147,7 +149,7 @@ class TestAiohttpSession:
|
|||
assert isinstance(fields[1][2], BareInputFile)
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_make_request(self, aresponses: ResponsesMockServer):
|
||||
async def test_make_request(self, bot: MockedBot, aresponses: ResponsesMockServer):
|
||||
aresponses.add(
|
||||
aresponses.ANY,
|
||||
"/bot42:TEST/method",
|
||||
|
|
@ -164,14 +166,14 @@ class TestAiohttpSession:
|
|||
class TestMethod(TelegramMethod[int]):
|
||||
__returning__ = int
|
||||
|
||||
def build_request(self) -> Request:
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
return Request(method="method", data={})
|
||||
|
||||
call = TestMethod()
|
||||
with patch(
|
||||
"aiogram.api.client.session.base.BaseSession.raise_for_status"
|
||||
) as patched_raise_for_status:
|
||||
result = await session.make_request("42:TEST", call)
|
||||
result = await session.make_request(bot, call)
|
||||
assert isinstance(result, int)
|
||||
assert result == 42
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue