mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 10:11:52 +00:00
PoC: Bot instance inside method shortcuts using pydantic Validation Context (#1210)
* PoC: Mount objects to the Bot instance, bind shortcuts to configured instance * Fixe docstring of the bind method * Pass Bot instance explicitly to the URLInputFile * Added tests * Added changelog * Refactor aiogram client and update tests Refactored base.py to improve code readability by separating response_type operation from model_validate(). Also, adjusted the parameters in URLInputFile() within test_input_file.py for better test coverage. Updated input_file.py to streamline read method and avoid unnecessary instantiation of Bot class. Lastly, adjusted typing in methods/base.py to enhance code clarity. * Update changelog
This commit is contained in:
parent
c39a803747
commit
a7b92bb050
19 changed files with 228 additions and 111 deletions
|
|
@ -22,6 +22,14 @@ class TestTelegramMethodRemoveUnset:
|
|||
|
||||
|
||||
class TestTelegramMethodCall:
|
||||
async def test_async_emit_unsuccessful(self, bot: MockedBot):
|
||||
with pytest.raises(
|
||||
RuntimeError,
|
||||
match="This method is not mounted to a any bot instance.+",
|
||||
):
|
||||
await GetMe()
|
||||
|
||||
async def test_async_emit(self, bot: MockedBot):
|
||||
bot.add_result_for(GetMe, ok=True, result=User(id=42, is_bot=True, first_name="Test"))
|
||||
assert isinstance(await GetMe(), User)
|
||||
method = GetMe().as_(bot)
|
||||
assert isinstance(await method, User)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue