mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 18:01:04 +00:00
Reworked request builder (#1142)
* Reworked request builder * Added more default values * Update tests * Fixed timestamp * Fixed Py3.8 support * Describe changes
This commit is contained in:
parent
924a83966d
commit
fea1b7b0a3
300 changed files with 1003 additions and 3448 deletions
|
|
@ -9,55 +9,11 @@ from tests.mocked_bot import MockedBot
|
|||
|
||||
|
||||
class TestAnswerInlineQuery:
|
||||
async def test_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(AnswerInlineQuery, ok=True, result=True)
|
||||
|
||||
response: bool = await AnswerInlineQuery(
|
||||
inline_query_id="query id", results=[InlineQueryResult()]
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "answerInlineQuery"
|
||||
assert response == prepare_result.result
|
||||
|
||||
async def test_bot_method(self, bot: MockedBot):
|
||||
prepare_result = bot.add_result_for(AnswerInlineQuery, ok=True, result=True)
|
||||
|
||||
response: bool = await bot.answer_inline_query(
|
||||
inline_query_id="query id", results=[InlineQueryResult()]
|
||||
)
|
||||
request: Request = bot.get_request()
|
||||
assert request.method == "answerInlineQuery"
|
||||
request = bot.get_request()
|
||||
assert response == prepare_result.result
|
||||
|
||||
def test_parse_mode(self, bot: MockedBot):
|
||||
query = AnswerInlineQuery(
|
||||
inline_query_id="query id",
|
||||
results=[
|
||||
InlineQueryResultPhoto(id="result id", photo_url="photo", thumbnail_url="thumb")
|
||||
],
|
||||
)
|
||||
request = query.build_request(bot)
|
||||
assert request.data["results"][0]["parse_mode"] is None
|
||||
|
||||
new_bot = Bot(token="42:TEST", parse_mode="HTML")
|
||||
request = query.build_request(new_bot)
|
||||
assert request.data["results"][0]["parse_mode"] == "HTML"
|
||||
|
||||
def test_parse_mode_input_message_content(self, bot: MockedBot):
|
||||
query = AnswerInlineQuery(
|
||||
inline_query_id="query id",
|
||||
results=[
|
||||
InlineQueryResultPhoto(
|
||||
id="result id",
|
||||
photo_url="photo",
|
||||
thumbnail_url="thumb",
|
||||
input_message_content=InputTextMessageContent(message_text="test"),
|
||||
)
|
||||
],
|
||||
)
|
||||
request = query.build_request(bot)
|
||||
assert request.data["results"][0]["input_message_content"]["parse_mode"] is None
|
||||
|
||||
new_bot = Bot(token="42:TEST", parse_mode="HTML")
|
||||
request = query.build_request(new_bot)
|
||||
assert request.data["results"][0]["input_message_content"]["parse_mode"] == "HTML"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue