Passed
Push — develop ( de44dd...df4f29 )
by Christophe
59s
created

MultiGraphicsTest.verify_conversion()   A

Complexity

Conditions 1

Size

Total Lines 38
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 18
nop 7
dl 0
loc 38
rs 9.5
c 0
b 0
f 0
1
"""Test module."""
2
from unittest import TestCase
3
4
from panflute import convert_text
5
6
import pandoc_beamer_multigraphics
7
8
9
class MultiGraphicsTest(TestCase):
10
    def verify_conversion(
11
        self,
12
        text,
13
        expected,
14
        transform,
15
        input_format="markdown",
16
        output_format="latex",
17
        standalone=False,  # noqa: FBT002
18
    ) -> None:
19
        """
20
        Verify the conversion.
21
22
        Parameters
23
        ----------
24
        text
25
            input text
26
        expected
27
            expected text
28
        transform
29
            filter function
30
        input_format
31
            input format
32
        output_format
33
            output format
34
        standalone
35
            is the output format standalone ?
36
        """
37
        doc = convert_text(text, input_format=input_format, standalone=True)
38
        doc.format = output_format
39
        doc = transform(doc)
40
        converted = convert_text(
41
            doc.content,
42
            input_format="panflute",
43
            output_format=output_format,
44
            extra_args=["--wrap=none"],
45
            standalone=standalone,
46
        )
47
        self.assertEqual(converted.strip(), expected.strip())  # noqa: PT009
48
49
    def test_simple(self):
50
        self.verify_conversion(
51
            """
52
---
53
pandoc-beamer-multigraphics:
54
  - classes: [multigraphics]
55
---
56
![](myimage){.multigraphics}
57
            """,
58
            """
59
\\begin{frame}
60
\\multiinclude[graphics={},format=pdf]{myimage}
61
\\end{frame}
62
            """,
63
            pandoc_beamer_multigraphics.main,
64
            output_format="beamer",
65
        )
66
67
    def test_complete(self):
68
        self.verify_conversion(
69
            """
70
---
71
pandoc-beamer-multigraphics:
72
  - classes: [multigraphics]
73
---
74
![](myimage){.multigraphics start=1 end=3}
75
            """,
76
            """
77
\\begin{frame}
78
\\multiinclude[graphics={},start=1,end=3,format=pdf]{myimage}
79
\\end{frame}
80
            """,
81
            pandoc_beamer_multigraphics.main,
82
            output_format="beamer",
83
        )
84
85
    def test_meta1(self):
86
        self.verify_conversion(
87
            """
88
---
89
pandoc-beamer-multigraphics:
90
  - classes: [multigraphics]
91
    format: png
92
    height: 20cm
93
---
94
![](myimage){.multigraphics}
95
            """,
96
            """
97
\\begin{frame}
98
\\multiinclude[graphics={height=20cm},format=png]{myimage}
99
\\end{frame}
100
            """,
101
            pandoc_beamer_multigraphics.main,
102
            output_format="beamer",
103
        )
104
105
    def test_meta2(self):
106
        self.verify_conversion(
107
            """
108
---
109
pandoc-beamer-multigraphics:
110
  - classes: [multigraphics]
111
    format: png
112
    width: 20cm
113
---
114
![](myimage){.multigraphics}
115
            """,
116
            """
117
\\begin{frame}
118
\\multiinclude[graphics={width=20cm},format=png]{myimage}
119
\\end{frame}
120
            """,
121
            pandoc_beamer_multigraphics.main,
122
            output_format="beamer",
123
        )
124