1
1
from os .path import exists
2
2
from os .path import join
3
3
4
+ import pytest
4
5
from django .conf import settings
5
6
from django .template import Context
6
7
from django .template import Template
17
18
site_packages = sysconfig .get_paths ()["purelib" ]
18
19
19
20
20
- def test_tag_use_in_template (version ):
21
+ @pytest .mark .parametrize (
22
+ "template_code" ,
23
+ [
24
+ "{% load mermaid %}{% mermaid content %}" ,
25
+ "{% load mermaid %}{% startmermaid %}{{ content|safe }}{% endmermaid %}"
26
+ ]
27
+ )
28
+ def test_tag_use_in_template (version , template_code ):
21
29
theme = getattr (settings , "MERMAID_THEME" , DEFAULT_THEME )
22
- template = Template ("{% load mermaid %}{% mermaid content %}" )
30
+ template = Template (template_code )
23
31
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
24
32
assert template == (
25
33
"<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
@@ -29,8 +37,15 @@ def test_tag_use_in_template(version):
29
37
30
38
31
39
@override_settings (MERMAID_THEME = "forest" )
32
- def test_tag_use_settings_theme (version ):
33
- template = Template ("{% load mermaid %}{% mermaid content %}" )
40
+ @pytest .mark .parametrize (
41
+ "template_code" ,
42
+ [
43
+ "{% load mermaid %}{% mermaid content %}" ,
44
+ "{% load mermaid %}{% startmermaid %}{{ content|safe }}{% endmermaid %}"
45
+ ]
46
+ )
47
+ def test_tag_use_settings_theme (version , template_code ):
48
+ template = Template (template_code )
34
49
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
35
50
assert template == (
36
51
"<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
@@ -39,8 +54,15 @@ def test_tag_use_settings_theme(version):
39
54
)
40
55
41
56
42
- def test_tag_use_custom_theme (version ):
43
- template = Template ("{% load mermaid %}{% mermaid content \" dark\" %}" )
57
+ @pytest .mark .parametrize (
58
+ "template_code" ,
59
+ [
60
+ "{% load mermaid %}{% mermaid content \" dark\" %}" ,
61
+ "{% load mermaid %}{% startmermaid \" dark\" %}{{ content|safe }}{% endmermaid %}"
62
+ ]
63
+ )
64
+ def test_tag_use_custom_theme (version , template_code ):
65
+ template = Template (template_code )
44
66
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
45
67
assert template == (
46
68
"<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
@@ -50,8 +72,15 @@ def test_tag_use_custom_theme(version):
50
72
51
73
52
74
@override_settings (MERMAID_THEME_VARIABLES = {"primaryColor" : "red" })
53
- def test_tag_use_custom_theme_variables (version ):
54
- template = Template ("{% load mermaid %}{% mermaid content \" dark\" %}" )
75
+ @pytest .mark .parametrize (
76
+ "template_code" ,
77
+ [
78
+ "{% load mermaid %}{% mermaid content \" dark\" %}" ,
79
+ "{% load mermaid %}{% startmermaid \" dark\" %}{{ content|safe }}{% endmermaid %}"
80
+ ]
81
+ )
82
+ def test_tag_use_custom_theme_variables (version , template_code ):
83
+ template = Template (template_code )
55
84
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
56
85
assert template == (
57
86
"<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
@@ -61,8 +90,15 @@ def test_tag_use_custom_theme_variables(version):
61
90
62
91
63
92
@override_settings (MERMAID_THEME = "base" , MERMAID_THEME_VARIABLES = {"primaryColor" : "#efefef" })
64
- def test_tag_use_custom_theme_variables_with_base_theme (version ):
65
- template = Template ("{% load mermaid %}{% mermaid content %}" )
93
+ @pytest .mark .parametrize (
94
+ "template_code" ,
95
+ [
96
+ "{% load mermaid %}{% mermaid content %}" ,
97
+ "{% load mermaid %}{% startmermaid %}{{ content|safe }}{% endmermaid %}"
98
+ ]
99
+ )
100
+ def test_tag_use_custom_theme_variables_with_base_theme (version , template_code ):
101
+ template = Template (template_code )
66
102
template = template .render (Context ({"content" : "graph LR; A-->B;" }))
67
103
assert template == (
68
104
"<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
0 commit comments