From be69feb25284f0d7dba3d7e6a8d96c55e72ae0de Mon Sep 17 00:00:00 2001 From: coder2020official Date: Sat, 22 Apr 2023 20:38:05 +0400 Subject: [PATCH] * Added a test for message entity __html_text function. #1971 should be fixed and then todo can be done. --- tests/test_types.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/test_types.py b/tests/test_types.py index c696f16..8c15396 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -271,5 +271,30 @@ def test_sent_web_app_message(): assert sent_web_app_message.inline_message_id == '29430' +def test_message_entity(): + # TODO: Add support for nesting entities + + + #sample_string_1 = r'{"update_id":934522126,"message":{"message_id":1374510,"from":{"id":927266710,"is_bot":false,"first_name":">_run","username":"coder2020","language_code":"en","is_premium":true},"chat":{"id":927266710,"first_name":">_run","username":"coder2020","type":"private"},"date":1682177590,"text":"b b b","entities":[{"offset":0,"length":2,"type":"bold"},{"offset":0,"length":1,"type":"italic"},{"offset":2,"length":2,"type":"bold"},{"offset":2,"length":1,"type":"italic"},{"offset":4,"length":1,"type":"bold"},{"offset":4,"length":1,"type":"italic"}]}}' + #update = types.Update.de_json(sample_string_1) + #message: types.Message = update.message + #assert message.html_text == "b b b" + + sample_string_2 = r'{"update_id":934522166,"message":{"message_id":1374526,"from":{"id":927266710,"is_bot":false,"first_name":">_run","username":"coder2020","language_code":"en","is_premium":true},"chat":{"id":927266710,"first_name":">_run","username":"coder2020","type":"private"},"date":1682179716,"text":"b b b","entities":[{"offset":0,"length":1,"type":"bold"},{"offset":2,"length":1,"type":"bold"},{"offset":4,"length":1,"type":"italic"}]}}' + message_2 = types.Update.de_json(sample_string_2).message + assert message_2.html_text == "b b b" + + + + #sample_string_3 = r'{"update_id":934522172,"message":{"message_id":1374530,"from":{"id":927266710,"is_bot":false,"first_name":">_run","username":"coder2020","language_code":"en","is_premium":true},"chat":{"id":927266710,"first_name":">_run","username":"coder2020","type":"private"},"date":1682179968,"text":"This is a bold text with a nested italic and bold text.","entities":[{"offset":10,"length":4,"type":"bold"},{"offset":27,"length":7,"type":"italic"},{"offset":34,"length":15,"type":"bold"},{"offset":34,"length":15,"type":"italic"}]}}' + #message_3 = types.Update.de_json(sample_string_3).message + #assert message_3.html_text == "This is a bold text with a nested italic and bold text." + + + assert True + + + +