From 3c2ac67d4e80f100b48e6234a9e13727d7d6a6eb Mon Sep 17 00:00:00 2001 From: Aleksandr Osovskii Date: Mon, 8 Jun 2026 13:22:15 +0300 Subject: [PATCH] markup link button without command --- pybotx/models/message/markup.py | 2 +- tests/models/test_botx_api_markup.py | 35 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pybotx/models/message/markup.py b/pybotx/models/message/markup.py index 587049dd..cb06c0b2 100644 --- a/pybotx/models/message/markup.py +++ b/pybotx/models/message/markup.py @@ -178,7 +178,7 @@ class BotXAPIButtonOptions(UnverifiedPayloadBaseModel): class BotXAPIButton(UnverifiedPayloadBaseModel): - command: str + command: Missing[str] label: str data: dict[str, Any] opts: BotXAPIButtonOptions diff --git a/tests/models/test_botx_api_markup.py b/tests/models/test_botx_api_markup.py index 850d4639..0d79c67b 100644 --- a/tests/models/test_botx_api_markup.py +++ b/tests/models/test_botx_api_markup.py @@ -1,11 +1,14 @@ import json +import warnings from typing import Any +from pybotx import BubbleMarkup from pybotx.models.message.markup import ( BotXAPIMarkup, BotXAPIButton, BotXAPIButtonOptions, + api_markup_from_domain, ) @@ -114,3 +117,35 @@ def test_botx_api_markup_jsonable_dict() -> None: ] ] assert jsonable_dict == expected_dict + + +def test_botx_api_markup_link_button_without_command() -> None: + # - Arrange - + markup = BubbleMarkup() + markup.add_button( + label="Open me", + link="https://example.com", + ) + + # - Act - + with warnings.catch_warnings(record=True) as captured_warnings: + warnings.simplefilter("always") + jsonable_dict = api_markup_from_domain(markup).jsonable_dict() + + # - Assert - + expected_dict: list[list[dict[str, Any]]] = [ + [ + { + "label": "Open me", + "data": {}, + "opts": { + "silent": True, + "align": "center", + "handler": "client", + "link": "https://example.com", + }, + } + ] + ] + assert jsonable_dict == expected_dict + assert not captured_warnings