Skip to content

Commit

Permalink
fix: add support init fields from parent object in KeyboardButton (#344)
Browse files Browse the repository at this point in the history
* fix: add support init fields from parent object in KeyboardButton

* fix: add tests
  • Loading branch information
Birdi7 committed May 31, 2020
1 parent cb0a898 commit 7076711
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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

0 comments on commit 7076711

Please sign in to comment.