-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
57 lines (47 loc) · 1.34 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import textwrap
from markdown import Markdown
from mdx_alerts import AlertExtension
def test_basic_conversion() -> None:
"""Test the basic conversion without additional parameters."""
# given
md = Markdown(extensions=[AlertExtension()])
pattern = textwrap.dedent(
"""
:: info
This is the body.
Even multi-line is possible.
::
"""
)
expected = textwrap.dedent("""\
<div class="alert alert-info" role="alert">
<h4 class="alert-heading"><strong>Info</strong></h4>
<p>This is the body.</p>
<p>Even multi-line is possible.</p>
</div>"""
)
# when
actual = md.convert(pattern)
# then
assert expected == actual
def test_conversion_overwriting_heading() -> None:
"""Test conversion with additional heading parameter."""
# given
md = Markdown(extensions=[AlertExtension()])
pattern = textwrap.dedent(
"""
:: info heading="Alternative Heading"
This is the body.
::
"""
)
expected = textwrap.dedent("""\
<div class="alert alert-info" role="alert">
<h4 class="alert-heading"><strong>Alternative Heading</strong></h4>
<p>This is the body.</p>
</div>"""
)
# when
actual = md.convert(pattern)
# then
assert expected == actual