forked from rnorth/mkdocs-codeinclude-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_plugin.py
More file actions
87 lines (60 loc) · 2.3 KB
/
Copy pathtest_plugin.py
File metadata and controls
87 lines (60 loc) · 2.3 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
import textwrap
import unittest
from mkdocs.config import Config, DEFAULT_SCHEMA
from mkdocs.structure.files import File
from mkdocs.structure.pages import Page
from codeinclude.plugin import CodeIncludePlugin
MARKDOWN_EXAMPLE = """
# hello world
some text before
<!--codeinclude-->
[foo](Foo.java)
<!--/codeinclude-->
and some text after
"""
MULTI_TAB_MARKDOWN_EXAMPLE = """
# hello world
some text before
<!--codeinclude-->
[foo](Foo.java)
[bar](Bar.java)
<!--/codeinclude-->
and some text after
"""
c = Config(schema=DEFAULT_SCHEMA)
c["site_url"] = "http://example.org/"
PAGE_EXAMPLE = Page("", File(os.path.abspath("./fixture/text.md"), "/src", "/dest", False), c)
class PluginTextCase(unittest.TestCase):
def test_simple_case(self):
plugin = CodeIncludePlugin()
result = plugin.on_page_markdown(MARKDOWN_EXAMPLE, PAGE_EXAMPLE, dict())
print(result)
self.assertEqual(textwrap.dedent("""
# hello world
some text before
```java tab=\"foo\"
public class Foo {
}
```
and some text after
""").strip(),
result.strip())
def test_multi_tab_case(self):
plugin = CodeIncludePlugin()
result = plugin.on_page_markdown(MULTI_TAB_MARKDOWN_EXAMPLE, PAGE_EXAMPLE, dict())
print(result)
self.assertEqual(textwrap.dedent("""
# hello world
some text before
```java tab=\"foo\"
public class Foo {
}
```
```java tab=\"bar\"
public class Bar {
}
```
and some text after
""").strip(),
result.strip())