mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-17 04:39:55 +01:00
Add User.send_poll (#1968)
This commit is contained in:
parent
c2d91c752f
commit
a42b68933c
2 changed files with 20 additions and 0 deletions
|
@ -296,3 +296,16 @@ class User(TelegramObject):
|
|||
|
||||
"""
|
||||
return self.bot.send_voice(self.id, *args, **kwargs)
|
||||
|
||||
def send_poll(self, *args, **kwargs):
|
||||
"""Shortcut for::
|
||||
|
||||
bot.send_poll(User.id, *args, **kwargs)
|
||||
|
||||
Where User is the current instance.
|
||||
|
||||
Returns:
|
||||
:class:`telegram.Message`: On success, instance representing the message posted.
|
||||
|
||||
"""
|
||||
return self.bot.send_poll(self.id, *args, **kwargs)
|
||||
|
|
|
@ -190,6 +190,13 @@ class TestUser(object):
|
|||
monkeypatch.setattr(user.bot, 'send_animation', test)
|
||||
assert user.send_animation('test_animation')
|
||||
|
||||
def test_instance_method_send_poll(self, monkeypatch, user):
|
||||
def test(*args, **kwargs):
|
||||
return args[0] == user.id and args[1] == 'test_poll'
|
||||
|
||||
monkeypatch.setattr(user.bot, 'send_poll', test)
|
||||
assert user.send_poll('test_poll')
|
||||
|
||||
def test_mention_html(self, user):
|
||||
expected = u'<a href="tg://user?id={}">{}</a>'
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue