mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 02:03:04 +00:00
Update and cover markdown utils
This commit is contained in:
parent
81e6c98088
commit
1d2c6c91d0
2 changed files with 104 additions and 54 deletions
45
tests/test_utils/test_markdown.py
Normal file
45
tests/test_utils/test_markdown.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
from typing import Any, Callable, Optional, Tuple
|
||||
|
||||
import pytest
|
||||
|
||||
from aiogram.utils import markdown
|
||||
|
||||
|
||||
class TestMarkdown:
|
||||
@pytest.mark.parametrize(
|
||||
"func,args,sep,result",
|
||||
[
|
||||
[markdown.text, ("test", "test"), " ", "test test"],
|
||||
[markdown.text, ("test", "test"), "\n", "test\ntest"],
|
||||
[markdown.text, ("test", "test"), None, "test test"],
|
||||
[markdown.bold, ("test", "test"), " ", "*test test*"],
|
||||
[markdown.hbold, ("test", "test"), " ", "<b>test test</b>"],
|
||||
[markdown.italic, ("test", "test"), " ", "_test test_"],
|
||||
[markdown.hitalic, ("test", "test"), " ", "<i>test test</i>"],
|
||||
[markdown.code, ("test", "test"), " ", "`test test`"],
|
||||
[markdown.hcode, ("test", "test"), " ", "<code>test test</code>"],
|
||||
[markdown.pre, ("test", "test"), " ", "```test test```"],
|
||||
[markdown.hpre, ("test", "test"), " ", "<pre>test test</pre>"],
|
||||
[markdown.underline, ("test", "test"), " ", "--test test--"],
|
||||
[markdown.hunderline, ("test", "test"), " ", "<u>test test</u>"],
|
||||
[markdown.strikethrough, ("test", "test"), " ", "~~test test~~"],
|
||||
[markdown.hstrikethrough, ("test", "test"), " ", "<s>test test</s>"],
|
||||
[markdown.link, ("test", "https://aiogram.dev"), None, "[test](https://aiogram.dev)"],
|
||||
[
|
||||
markdown.hlink,
|
||||
("test", "https://aiogram.dev"),
|
||||
None,
|
||||
'<a href="https://aiogram.dev">test</a>',
|
||||
],
|
||||
[
|
||||
markdown.hide_link,
|
||||
("https://aiogram.dev",),
|
||||
None,
|
||||
'<a href="https://aiogram.dev">​</a>',
|
||||
],
|
||||
],
|
||||
)
|
||||
def test_formatter(
|
||||
self, func: Callable[[Any], Any], args: Tuple[str], sep: Optional[str], result: str
|
||||
):
|
||||
assert func(*args, **({"sep": sep} if sep is not None else {})) == result # type: ignore
|
||||
Loading…
Add table
Add a link
Reference in a new issue