Skip to content

Commit

Permalink
feat: Human-friendly button diff in tests (#397)
Browse files Browse the repository at this point in the history
  • Loading branch information
siderai committed Jun 7, 2023
1 parent 2934c74 commit f8bae38
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
12 changes: 12 additions & 0 deletions pybotx/models/message/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ def __eq__(self, other: object) -> bool:
# https://github.com/wemake-services/wemake-python-styleguide/issues/2172
return self._buttons == other._buttons # noqa: WPS437

def __repr__(self) -> str:
buttons = []

for idx, row in enumerate(self._buttons, start=1):
row_buttons_strings = [
f"{button.label} ({button.command})" for button in row
]
row_string = " | ".join(row_buttons_strings)
buttons.append(f"row {idx}: {row_string}")

return "\n".join(buttons)

def add_built_button(self, button: Button, new_row: bool = True) -> None:
if new_row:
self._buttons.append([button])
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pybotx"
version = "0.55.3"
version = "0.55.4"
description = "A python library for interacting with eXpress BotX API"
authors = [
"Sidnev Nikolay <nsidnev@ccsteam.ru>",
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ per-file-ignores =
# Allow using methods names with trailing underscore
pybotx/models/enums.py:WPS120

tests/*:DAR101,E501,WPS110,WPS114,WPS116,WPS118,WPS202,WPS221,WPS226,WPS237,WPS402,WPS420,WPS428,WPS430,WPS432,WPS441,WPS442,WPS520,PT011,S105,S106
tests/*:DAR101,E501,WPS110,WPS114,WPS116,WPS118,WPS202,WPS221,WPS226,WPS237,WPS402,WPS420,WPS428,WPS430,WPS432,WPS441,WPS442,WPS520,PT011,S105,S106,WPS609

# Import ignores for README lint
.snippets/*:F403,F405,WPS347,WPS421,S106
Expand Down
15 changes: 15 additions & 0 deletions tests/models/test_markup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pybotx import BubbleMarkup


def test__mentions_list_properties__filled() -> None:
# - Arrange -
bubbles = BubbleMarkup()
bubbles.add_button("command1", "label1")
bubbles.add_button("command2", "label2")
bubbles.add_button("command3", "label3", new_row=False)

# - Assert -
assert (
bubbles.__repr__()
== "row 1: label1 (command1)\nrow 2: label2 (command2) | label3 (command3)"
)

0 comments on commit f8bae38

Please sign in to comment.