Add User.send_poll (#1968)

This commit is contained in:
Bibo-Joshi 2020-05-27 21:59:49 +02:00 committed by GitHub
parent c2d91c752f
commit a42b68933c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -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)

View file

@ -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>'