mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Added more details when server send invalid response
This commit is contained in:
parent
44ae565149
commit
efae83d337
4 changed files with 56 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ from aiogram import Bot
|
|||
from aiogram.client.session.base import BaseSession, TelegramType
|
||||
from aiogram.client.telegram import PRODUCTION, TelegramAPIServer
|
||||
from aiogram.exceptions import (
|
||||
ClientDecodeError,
|
||||
RestartingTelegram,
|
||||
TelegramAPIError,
|
||||
TelegramBadRequest,
|
||||
|
|
@ -183,6 +184,28 @@ class TestBaseSession:
|
|||
if error.url:
|
||||
assert error.url in string
|
||||
|
||||
def test_check_response_json_decode_error(self):
|
||||
session = CustomSession()
|
||||
method = DeleteMessage(chat_id=42, message_id=42)
|
||||
|
||||
with pytest.raises(ClientDecodeError, match="JSONDecodeError"):
|
||||
session.check_response(
|
||||
method=method,
|
||||
status_code=200,
|
||||
content="is not a JSON object",
|
||||
)
|
||||
|
||||
def test_check_response_validation_error(self):
|
||||
session = CustomSession()
|
||||
method = DeleteMessage(chat_id=42, message_id=42)
|
||||
|
||||
with pytest.raises(ClientDecodeError, match="ValidationError"):
|
||||
session.check_response(
|
||||
method=method,
|
||||
status_code=200,
|
||||
content='{"ok": "test"}',
|
||||
)
|
||||
|
||||
async def test_make_request(self):
|
||||
session = CustomSession()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue