From 8db5f49f75344e84c2ea42b22a63fdcb704efd33 Mon Sep 17 00:00:00 2001 From: Leonid Gorbunov Date: Mon, 14 Jul 2025 17:04:17 +0800 Subject: [PATCH] fix: get_smartapp_list smartapp.name set as optional --- pybotx/client/smartapps_api/smartapps_list.py | 2 +- pybotx/models/smartapps.py | 2 +- pyproject.toml | 2 +- .../smartapps_api/test_smartapps_list.py | 55 +++++++++++++++++++ 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/pybotx/client/smartapps_api/smartapps_list.py b/pybotx/client/smartapps_api/smartapps_list.py index 0097f4be..867b7034 100644 --- a/pybotx/client/smartapps_api/smartapps_list.py +++ b/pybotx/client/smartapps_api/smartapps_list.py @@ -22,7 +22,7 @@ class BotXAPISmartAppEntity(VerifiedPayloadBaseModel): app_id: str enabled: bool id: UUID - name: str + name: Optional[str] = None avatar: Optional[str] = None avatar_preview: Optional[str] = None diff --git a/pybotx/models/smartapps.py b/pybotx/models/smartapps.py index 75b10cc0..227d3c80 100644 --- a/pybotx/models/smartapps.py +++ b/pybotx/models/smartapps.py @@ -19,6 +19,6 @@ class SmartApp: app_id: str enabled: bool id: UUID - name: str + name: Optional[str] = None avatar: Optional[str] = None avatar_preview: Optional[str] = None diff --git a/pyproject.toml b/pyproject.toml index 6bb84255..941f26dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pybotx" -version = "0.75.1" +version = "0.75.2" description = "A python library for interacting with eXpress BotX API" authors = [ "Sidnev Nikolay ", diff --git a/tests/client/smartapps_api/test_smartapps_list.py b/tests/client/smartapps_api/test_smartapps_list.py index 8c955a65..d54f849c 100644 --- a/tests/client/smartapps_api/test_smartapps_list.py +++ b/tests/client/smartapps_api/test_smartapps_list.py @@ -69,3 +69,58 @@ async def test__smartapps_list__succeed( ), ] assert version == 1 + + +async def test__smartapps_list__succeed_without_name( + respx_mock: MockRouter, + host: str, + bot_id: UUID, + bot_account: BotAccountWithSecret, +) -> None: + # - Arrange - + endpoint = respx_mock.get( + f"https://{host}/api/v3/botx/smartapps/list", + headers={"Authorization": "Bearer token"}, + ).mock( + return_value=httpx.Response( + HTTPStatus.OK, + json={ + "result": { + "phonebook_version": 1, + "smartapps": [ + { + "app_id": "amazing_smartapp", + "avatar": "https://cts.example.com/uploads/profile_avatar/foo", + "avatar_preview": "https://cts.example.com/uploads/profile_avatar/bar", + "enabled": True, + "id": "dc4acaf2-310f-4b0f-aec7-253b9def42ac", + "name": None, + }, + ], + }, + "status": "ok", + }, + ), + ) + + built_bot = Bot(collectors=[HandlerCollector()], bot_accounts=[bot_account]) + + # - Act - + async with lifespan_wrapper(built_bot) as bot: + smartapps_list, version = await bot.get_smartapps_list( + bot_id=bot_id, + ) + + # - Assert - + assert endpoint.called + assert smartapps_list == [ + SmartApp( + app_id="amazing_smartapp", + avatar="https://cts.example.com/uploads/profile_avatar/foo", + avatar_preview="https://cts.example.com/uploads/profile_avatar/bar", + enabled=True, + id=UUID("dc4acaf2-310f-4b0f-aec7-253b9def42ac"), + name=None, + ), + ] + assert version == 1