Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pybotx/models/message/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class BotXAPIButtonOptions(UnverifiedPayloadBaseModel):


class BotXAPIButton(UnverifiedPayloadBaseModel):
command: str
command: Missing[str]
label: str
data: dict[str, Any]
opts: BotXAPIButtonOptions
Expand Down
35 changes: 35 additions & 0 deletions tests/models/test_botx_api_markup.py
Original file line number Diff line number Diff line change
@@ -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,
)


Expand Down Expand Up @@ -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
Loading