Passed
Push — develop ( 2ab520...3348f4 )
by Christophe
01:09
created

test_block.BlockTest.test_theorem()   A

Complexity

Conditions 1

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 21
rs 9.85
c 0
b 0
f 0
cc 1
nop 1
1
# This Python file uses the following encoding: utf-8
2
3
from unittest import TestCase
4
5
from panflute import convert_text, Para, Image
6
7
import pandoc_beamer_block
8
9
10
class BlockTest(TestCase):
11
    @classmethod
12
    def conversion(cls, markdown, fmt="markdown"):
13
        doc = convert_text(markdown, standalone=True)
14
        doc.format = fmt
15
        pandoc_beamer_block.main(doc)
16
        return doc
17
18
    def test_simple(self):
19
        doc = BlockTest.conversion(
20
            """
21
---
22
pandoc-beamer-block:
23
  - classes: ['class1', 'class2']
24
---
25
::: {.class1 .class2}
26
:::
27
            """,
28
            "beamer",
29
        )
30
        text = convert_text(
31
            doc,
32
            input_format="panflute",
33
            output_format="latex",
34
            extra_args=["--wrap=none"],
35
        )
36
        self.assertIn("\\begin{block}", text)
37
        self.assertIn("\\end{block}", text)
38
39
    def test_title(self):
40
        doc = BlockTest.conversion(
41
            """
42
---
43
pandoc-beamer-block:
44
  - classes: ['class1', 'class2']
45
---
46
::: {.class1 .class2 title="My Title"}
47
:::
48
            """,
49
            "beamer",
50
        )
51
        text = convert_text(
52
            doc,
53
            input_format="panflute",
54
            output_format="latex",
55
            extra_args=["--wrap=none"],
56
        )
57
        self.assertIn("\\begin{block}{My Title}", text)
58
        self.assertIn("\\end{block}", text)
59
60
    def test_theorem(self):
61
        doc = BlockTest.conversion(
62
            """
63
---
64
pandoc-beamer-block:
65
  - classes: ['theorem']
66
    type: theorem
67
---
68
::: {.theorem title="My Title"}
69
:::
70
            """,
71
            "beamer",
72
        )
73
        text = convert_text(
74
            doc,
75
            input_format="panflute",
76
            output_format="latex",
77
            extra_args=["--wrap=none"],
78
        )
79
        self.assertIn("\\begin{theorem}[My Title]", text)
80
        self.assertIn("\\end{theorem}", text)
81
82
    def test_alert(self):
83
        doc = BlockTest.conversion(
84
            """
85
---
86
pandoc-beamer-block:
87
  - classes: ['class1', 'class2']
88
    type: alert
89
---
90
::: {.class1 .class2}
91
:::
92
            """,
93
            "beamer",
94
        )
95
        text = convert_text(
96
            doc,
97
            input_format="panflute",
98
            output_format="latex",
99
            extra_args=["--wrap=none"],
100
        )
101
        self.assertIn("\\begin{alertblock}", text)
102
        self.assertIn("\\end{alertblock}", text)
103
104
    def test_example(self):
105
        doc = BlockTest.conversion(
106
            """
107
---
108
pandoc-beamer-block:
109
  - classes: ['class1', 'class2']
110
    type: example
111
---
112
::: {.class1 .class2}
113
:::
114
            """,
115
            "beamer",
116
        )
117
        text = convert_text(
118
            doc,
119
            input_format="panflute",
120
            output_format="latex",
121
            extra_args=["--wrap=none"],
122
        )
123
        self.assertIn("\\begin{exampleblock}", text)
124
        self.assertIn("\\end{exampleblock}", text)
125
126
    def test_title_complex(self):
127
        doc = BlockTest.conversion(
128
            """
129
---
130
pandoc-beamer-block:
131
  - classes: ['class1', 'class2']
132
---
133
::: {.class1 .class2 title="**My Title**"}
134
:::
135
            """,
136
            "beamer",
137
        )
138
        text = convert_text(
139
            doc,
140
            input_format="panflute",
141
            output_format="latex",
142
            extra_args=["--wrap=none"],
143
        )
144
        self.assertIn("\\begin{block}{\\textbf{My Title}}", text)
145
        self.assertIn("\\end{block}", text)
146