mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 19:00:23 +00:00
Fixed error overlapping when validation error is caused by remove_unset root validator in base types and methods. (#1290)
* Ensure base type validation can handle non-dictionary values The update introduces a condition to verify whether the values being validated are a dictionary before attempting to handle UNSET_TYPE in the aiogram base type. This adjustment helps to prevent potential errors or incorrect validation when non-dictionary values are faced. * Added a test case for non-dictionary input in remove_unset method * Added changelog * Fixed tests
This commit is contained in:
parent
e1be9dd668
commit
04bd0c9e7c
4 changed files with 13 additions and 3 deletions
|
|
@ -3,7 +3,7 @@ from unittest.mock import sentinel
|
|||
import pytest
|
||||
|
||||
from aiogram.methods import GetMe, TelegramMethod
|
||||
from aiogram.types import User
|
||||
from aiogram.types import User, TelegramObject
|
||||
from tests.mocked_bot import MockedBot
|
||||
|
||||
|
||||
|
|
@ -16,10 +16,15 @@ class TestTelegramMethodRemoveUnset:
|
|||
[{"foo": "bar", "baz": sentinel.DEFAULT}, {"foo"}],
|
||||
],
|
||||
)
|
||||
def test_remove_unset(self, values, names):
|
||||
validated = TelegramMethod.remove_unset(values)
|
||||
@pytest.mark.parametrize("obj", [TelegramMethod, TelegramObject])
|
||||
def test_remove_unset(self, values, names, obj):
|
||||
validated = obj.remove_unset(values)
|
||||
assert set(validated.keys()) == names
|
||||
|
||||
@pytest.mark.parametrize("obj", [TelegramMethod, TelegramObject])
|
||||
def test_remove_unset_non_dict(self, obj):
|
||||
assert obj.remove_unset("") == ""
|
||||
|
||||
|
||||
class TestTelegramMethodCall:
|
||||
async def test_async_emit_unsuccessful(self, bot: MockedBot):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue