mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fixed tests
This commit is contained in:
parent
ef18c3570a
commit
639c0581e2
2 changed files with 9 additions and 5 deletions
|
|
@ -61,6 +61,8 @@ class TelegramMethod(BotContextController, BaseModel, Generic[TelegramType], ABC
|
|||
but UNSET might be passing to a model initialization from `Bot.method_name`,
|
||||
so we must take care of it and remove it before fields validation.
|
||||
"""
|
||||
if not isinstance(values, dict):
|
||||
return values
|
||||
return {k: v for k, v in values.items() if not isinstance(v, UNSET_TYPE)}
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
|
|
|||
|
|
@ -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,12 +16,14 @@ 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
|
||||
|
||||
def test_remove_unset_non_dict(self):
|
||||
assert TelegramMethod.remove_unset("") == ""
|
||||
@pytest.mark.parametrize("obj", [TelegramMethod, TelegramObject])
|
||||
def test_remove_unset_non_dict(self, obj):
|
||||
assert obj.remove_unset("") == ""
|
||||
|
||||
|
||||
class TestTelegramMethodCall:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue