mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 14:35:00 +01:00
parent
5c8470e552
commit
d347c0d45e
2 changed files with 16 additions and 0 deletions
|
@ -83,6 +83,17 @@ class User(TelegramObject):
|
|||
return '%s %s' % (self.first_name, self.last_name)
|
||||
return self.first_name
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
"""
|
||||
:obj:`str`: The users :attr:`first_name` and if present :attr:`last_name`.
|
||||
|
||||
"""
|
||||
|
||||
if self.last_name:
|
||||
return '%s %s' % (self.first_name, self.last_name)
|
||||
return self.first_name
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data, bot):
|
||||
if not data:
|
||||
|
|
|
@ -90,6 +90,11 @@ class TestUser(object):
|
|||
assert user.name == 'first_name'
|
||||
user.username = self.username
|
||||
assert user.name == '@username'
|
||||
|
||||
def test_full_name(self, user):
|
||||
assert user.full_name == 'first_name last_name'
|
||||
user.last_name = None
|
||||
assert user.full_name == 'first_name'
|
||||
|
||||
def test_get_profile_photos(self, monkeypatch, user):
|
||||
def test(_, *args, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue