From ca1545905b09be75181485f8977ccbdfd7c084a7 Mon Sep 17 00:00:00 2001 From: eternnoir Date: Fri, 26 Jun 2015 22:22:18 +0800 Subject: [PATCH] Add Group Message deJson test. --- tests/test_types.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test_types.py b/tests/test_types.py index 6dbb5b7..6181872 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -14,9 +14,16 @@ def test_json_user(): 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"}' 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(): json_string = r'{"id":8926,"title":"\u5c4e\u4f2f\u98ef\u98ef\u4e4b\u4ea4"}' gc = types.GroupChat.de_json(json_string) - assert gc.id is not 8926 \ No newline at end of file + assert gc.id == 8926 \ No newline at end of file