Add different shortcut methods for Text.as_kwargs() (#1657)

* Add different shortcut methods for Text.as_kwargs()

New methods:
- as_caption_kwargs()
- as_poll_question_kwargs()
- as_poll_explanation_kwargs()
- as_gift_text_kwargs()

* Add changelog

* Fix not passing linter checks
This commit is contained in:
Anton Trotsenko 2025-04-02 22:16:55 +02:00 committed by GitHub
parent 7e8dcc6852
commit 5547963311
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 114 additions and 1 deletions

View file

@ -172,6 +172,34 @@ class TestNode:
assert "parse_mode" not in result
assert "custom_parse_mode" in result
def test_as_caption_kwargs(self):
node = Text("Hello, ", Bold("World"), "!")
result = node.as_caption_kwargs()
assert "caption" in result
assert "caption_entities" in result
assert "parse_mode" in result
def test_as_poll_question_kwargs(self):
node = Text("Hello, ", Bold("World"), "!")
result = node.as_poll_question_kwargs()
assert "question" in result
assert "question_entities" in result
assert "question_parse_mode" in result
def test_as_poll_explanation_kwargs(self):
node = Text("Hello, ", Bold("World"), "!")
result = node.as_poll_explanation_kwargs()
assert "explanation" in result
assert "explanation_entities" in result
assert "explanation_parse_mode" in result
def test_as_as_gift_text_kwargs_kwargs(self):
node = Text("Hello, ", Bold("World"), "!")
result = node.as_gift_text_kwargs()
assert "text" in result
assert "text_entities" in result
assert "text_parse_mode" in result
def test_as_html(self):
node = Text("Hello, ", Bold("World"), "!")
assert node.as_html() == "Hello, <b>World</b>!"