mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fixed coverage
This commit is contained in:
parent
e30e89a789
commit
222d48ea09
2 changed files with 6 additions and 20 deletions
|
|
@ -106,7 +106,7 @@ class KeyboardBuilder(Generic[ButtonType], ABC):
|
|||
f"not type {type(row).__name__}"
|
||||
)
|
||||
if len(row) > self.max_width:
|
||||
raise ValueError(f"Row {row!r} is too long (MAX_WIDTH={self.max_width})")
|
||||
raise ValueError(f"Row {row!r} is too long (max width: {self.max_width})")
|
||||
self._validate_buttons(*row)
|
||||
return True
|
||||
|
||||
|
|
@ -144,14 +144,6 @@ class KeyboardBuilder(Generic[ButtonType], ABC):
|
|||
raise ValueError(f"Row size {size} are not allowed")
|
||||
return size
|
||||
|
||||
def copy(self: "KeyboardBuilder[ButtonType]") -> "KeyboardBuilder[ButtonType]":
|
||||
"""
|
||||
Make full copy of current builder with markup
|
||||
|
||||
:return:
|
||||
"""
|
||||
return self.__class__(self._button_type, markup=self.export())
|
||||
|
||||
def export(self) -> List[List[ButtonType]]:
|
||||
"""
|
||||
Export configured markup as list of lists of buttons
|
||||
|
|
|
|||
|
|
@ -78,27 +78,21 @@ class TestKeyboardBuilder:
|
|||
row=[KeyboardButton(text=f"test {index}") for index in range(count)]
|
||||
)
|
||||
|
||||
def test_validate_markup(self):
|
||||
def test_validate_markup_invalid_type(self):
|
||||
builder = ReplyKeyboardBuilder()
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
builder._validate_markup(markup=())
|
||||
|
||||
def test_validate_markup_too_many_buttons(self):
|
||||
builder = ReplyKeyboardBuilder()
|
||||
with pytest.raises(ValueError):
|
||||
builder._validate_markup(
|
||||
markup=[
|
||||
[KeyboardButton(text=f"{row}.{col}") for col in range(builder.max_width + 5)]
|
||||
for row in range(5)
|
||||
[KeyboardButton(text=f"{row}.{col}") for col in range(builder.max_width)]
|
||||
for row in range(builder.max_buttons)
|
||||
]
|
||||
)
|
||||
|
||||
assert builder._validate_markup(
|
||||
markup=[
|
||||
[KeyboardButton(text=f"{row}.{col}") for col in range(builder.max_width)]
|
||||
for row in range(5)
|
||||
]
|
||||
)
|
||||
|
||||
def test_validate_size(self):
|
||||
builder = ReplyKeyboardBuilder()
|
||||
with pytest.raises(ValueError):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue