diff --git a/pybotx/models/message/markup.py b/pybotx/models/message/markup.py index c7b67b20..832a622d 100644 --- a/pybotx/models/message/markup.py +++ b/pybotx/models/message/markup.py @@ -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]) diff --git a/pyproject.toml b/pyproject.toml index 1fb3ca87..70c7b385 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 ", diff --git a/setup.cfg b/setup.cfg index 522acbb2..06a2d3dd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/tests/models/test_markup.py b/tests/models/test_markup.py new file mode 100644 index 00000000..87ade162 --- /dev/null +++ b/tests/models/test_markup.py @@ -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)" + )