Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add support init fields from parent object in KeyboardButton #344

Merged
merged 2 commits into from
May 31, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions aiogram/types/reply_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ class KeyboardButton(base.TelegramObject):
def __init__(self, text: base.String,
request_contact: base.Boolean = None,
request_location: base.Boolean = None,
request_poll: KeyboardButtonPollType = None):
request_poll: KeyboardButtonPollType = None,
**kwargs):
super(KeyboardButton, self).__init__(text=text,
request_contact=request_contact,
request_location=request_location,
request_poll=request_poll)
request_poll=request_poll,
**kwargs)


class ReplyKeyboardRemove(base.TelegramObject):
Expand Down
5 changes: 5 additions & 0 deletions tests/types/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,8 @@
"has_custom_certificate": False,
"pending_update_count": 0,
}

REPLY_KEYBOARD_MARKUP = {
"keyboard": [[{"text": "something here"}]],
"resize_keyboard": True,
}
12 changes: 12 additions & 0 deletions tests/types/test_reply_keyboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from aiogram import types
from .dataset import REPLY_KEYBOARD_MARKUP

reply_keyboard = types.ReplyKeyboardMarkup(**REPLY_KEYBOARD_MARKUP)


def test_serialize():
assert reply_keyboard.to_python() == REPLY_KEYBOARD_MARKUP


def test_deserialize():
assert reply_keyboard.to_object(reply_keyboard.to_python()) == reply_keyboard