1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

add PollAnswer, poll_answer_handler; make User Serializable and Dictionaryble; some pep fixes

This commit is contained in:
dr_forse
2020-05-12 01:09:34 +01:00
parent aacc494a55
commit 75a018e18b
3 changed files with 82 additions and 5 deletions

View File

@@ -178,4 +178,13 @@ def test_json_poll_1():
assert msg.poll.question is not None
assert msg.poll.options is not None
assert len(msg.poll.options) == 2
assert msg.poll.allows_multiple_answers == True
assert msg.poll.allows_multiple_answers is True
def test_json_poll_answer():
jsonstring = r'{"poll_id": "5895675970559410186", "user": {"id": 329343347, "is_bot": false, "first_name": "Test", "username": "test_user", "last_name": "User", "language_code": "en"}, "option_ids": [1]}'
__import__('pprint').pprint(__import__('json').loads(jsonstring))
poll_answer = types.PollAnswer.de_json(jsonstring)
assert poll_answer.poll_id == '5895675970559410186'
assert isinstance(poll_answer.user, types.User)
assert poll_answer.options_ids == [1]