11from os .path import exists
22from os .path import join
33
4+ import pytest
45from django .conf import settings
56from django .template import Context
67from django .template import Template
1718 site_packages = sysconfig .get_paths ()["purelib" ]
1819
1920
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 ):
2129 theme = getattr (settings , "MERMAID_THEME" , DEFAULT_THEME )
22- template = Template ("{% load mermaid %}{% mermaid content %}" )
30+ template = Template (template_code )
2331 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
2432 assert template == (
2533 "<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):
2937
3038
3139@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 )
3449 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
3550 assert template == (
3651 "<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):
3954 )
4055
4156
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 )
4466 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
4567 assert template == (
4668 "<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):
5072
5173
5274@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 )
5584 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
5685 assert template == (
5786 "<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):
6190
6291
6392@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 )
66102 template = template .render (Context ({"content" : "graph LR; A-->B;" }))
67103 assert template == (
68104 "<div class=\" mermaid\" >graph LR; A-->B;</div><script src=\" mermaid/%s/mermaid.js\" ></script>"
0 commit comments