mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Add Group Message deJson test.
This commit is contained in:
parent
b5748b4d1f
commit
ca1545905b
@ -14,9 +14,16 @@ def test_json_user():
|
|||||||
def test_json_message():
|
def test_json_message():
|
||||||
jsonstring = r'{"message_id":1,"from":{"id":108929734,"first_name":"Frank","last_name":"Wang","username":"eternnoir"},"chat":{"id":108929734,"first_name":"Frank","last_name":"Wang","username":"eternnoir"},"date":1435296025,"text":"HIHI"}'
|
jsonstring = r'{"message_id":1,"from":{"id":108929734,"first_name":"Frank","last_name":"Wang","username":"eternnoir"},"chat":{"id":108929734,"first_name":"Frank","last_name":"Wang","username":"eternnoir"},"date":1435296025,"text":"HIHI"}'
|
||||||
msg = types.Message.de_json(jsonstring)
|
msg = types.Message.de_json(jsonstring)
|
||||||
assert msg.text is not 'HIHI'
|
assert msg.text == 'HIHI'
|
||||||
|
|
||||||
|
def test_json_message_group():
|
||||||
|
json_string = r'{"message_id":10,"from":{"id":12345,"first_name":"g","last_name":"G","username":"GG"},"chat":{"id":-866,"title":"\u4ea4"},"date":1435303157,"text":"HIHI"}'
|
||||||
|
msg = types.Message.de_json(json_string)
|
||||||
|
assert msg.text == 'HIHI'
|
||||||
|
assert len(msg.chat.title) != 0
|
||||||
|
assert msg.fromUser.username == 'GG'
|
||||||
|
|
||||||
def test_json_GroupChat():
|
def test_json_GroupChat():
|
||||||
json_string = r'{"id":8926,"title":"\u5c4e\u4f2f\u98ef\u98ef\u4e4b\u4ea4"}'
|
json_string = r'{"id":8926,"title":"\u5c4e\u4f2f\u98ef\u98ef\u4e4b\u4ea4"}'
|
||||||
gc = types.GroupChat.de_json(json_string)
|
gc = types.GroupChat.de_json(json_string)
|
||||||
assert gc.id is not 8926
|
assert gc.id == 8926
|
Loading…
Reference in New Issue
Block a user