mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-03 09:49:21 +01:00
Improve tests for GroupChat and User
This commit is contained in:
parent
5c0eeac036
commit
073d43fd75
2 changed files with 26 additions and 1 deletions
|
@ -39,6 +39,14 @@ class GroupChatTest(BaseTest, unittest.TestCase):
|
|||
'title': self.title
|
||||
}
|
||||
|
||||
def test_group_chat_de_json_empty_json(self):
|
||||
"""Test GroupChat.de_json() method"""
|
||||
print('Testing GroupChat.de_json() - Empty JSON')
|
||||
|
||||
group_chat = telegram.GroupChat.de_json({})
|
||||
|
||||
self.assertEqual(group_chat, None)
|
||||
|
||||
def test_group_chat_de_json(self):
|
||||
"""Test GroupChat.de_json() method"""
|
||||
print('Testing GroupChat.de_json()')
|
||||
|
|
|
@ -70,7 +70,24 @@ class UserTest(BaseTest, unittest.TestCase):
|
|||
self.assertEqual(user.first_name, self.first_name)
|
||||
self.assertEqual(user.last_name, self.last_name)
|
||||
|
||||
self.assertEqual(user.name, 'Leandro S.')
|
||||
self.assertEqual(user.name, '%s %s' % (self.first_name, self.last_name))
|
||||
|
||||
|
||||
def test_user_de_json_without_username_and_lastname(self):
|
||||
"""Test User.de_json() method"""
|
||||
print('Testing User.de_json() - Without username and last_name')
|
||||
|
||||
json_dict = self.json_dict
|
||||
|
||||
del(json_dict['username'])
|
||||
del(json_dict['last_name'])
|
||||
|
||||
user = telegram.User.de_json(self.json_dict)
|
||||
|
||||
self.assertEqual(user.id, self.id)
|
||||
self.assertEqual(user.first_name, self.first_name)
|
||||
|
||||
self.assertEqual(user.name, self.first_name)
|
||||
|
||||
def test_user_to_json(self):
|
||||
"""Test User.to_json() method"""
|
||||
|
|
Loading…
Reference in a new issue