@@ -16,77 +16,77 @@ class DummyTechDocsCorePlugin(plugins.BasePlugin):
16
16
pass
17
17
18
18
19
- class TestTechDocsCoreConfig (unittest .TestCase ):
19
+ class TestTechDocsCore (unittest .TestCase ):
20
20
def setUp (self ):
21
- self .techdocscore = TechDocsCore ()
22
21
self .plugin_collection = plugins .PluginCollection ()
23
22
plugin = DummyTechDocsCorePlugin ()
24
23
self .plugin_collection ["techdocs-core" ] = plugin
25
- self .mkdocs_yaml_config = {"plugins" : self .plugin_collection }
26
- # Note: in reality, config["theme"] is always an instance of Theme
27
- self .mkdocs_yaml_config ["theme" ] = get_default_theme ()
24
+ self .techdocscore = TechDocsCore ()
25
+ self .techdocscore .load_config (
26
+ {"plugins" : self .plugin_collection , "theme" : get_default_theme ()}
27
+ )
28
28
29
29
def test_removes_techdocs_core_plugin_from_config (self ):
30
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
30
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
31
31
self .assertTrue ("techdocs-core" not in final_config ["plugins" ])
32
32
33
33
def test_merge_default_config_and_user_config (self ):
34
- self .mkdocs_yaml_config ["markdown_extension" ] = []
35
- self .mkdocs_yaml_config ["mdx_configs" ] = {}
36
- self .mkdocs_yaml_config ["markdown_extension" ].append (["toc" ])
37
- self .mkdocs_yaml_config ["mdx_configs" ]["toc" ] = {"toc_depth" : 3 }
38
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
34
+ self .techdocscore . config ["markdown_extension" ] = []
35
+ self .techdocscore . config ["mdx_configs" ] = {}
36
+ self .techdocscore . config ["markdown_extension" ].append (["toc" ])
37
+ self .techdocscore . config ["mdx_configs" ]["toc" ] = {"toc_depth" : 3 }
38
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
39
39
self .assertTrue ("toc" in final_config ["mdx_configs" ])
40
40
self .assertTrue ("permalink" in final_config ["mdx_configs" ]["toc" ])
41
41
self .assertTrue ("toc_depth" in final_config ["mdx_configs" ]["toc" ])
42
42
self .assertTrue ("mdx_truly_sane_lists" in final_config ["markdown_extensions" ])
43
43
44
44
def test_override_default_config_with_user_config (self ):
45
- self .mkdocs_yaml_config ["markdown_extension" ] = []
46
- self .mkdocs_yaml_config ["mdx_configs" ] = {}
47
- self .mkdocs_yaml_config ["markdown_extension" ].append (["toc" ])
48
- self .mkdocs_yaml_config ["mdx_configs" ]["toc" ] = {"permalink" : False }
49
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
45
+ self .techdocscore . config ["markdown_extension" ] = []
46
+ self .techdocscore . config ["mdx_configs" ] = {}
47
+ self .techdocscore . config ["markdown_extension" ].append (["toc" ])
48
+ self .techdocscore . config ["mdx_configs" ]["toc" ] = {"permalink" : False }
49
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
50
50
self .assertTrue ("toc" in final_config ["mdx_configs" ])
51
51
self .assertTrue ("permalink" in final_config ["mdx_configs" ]["toc" ])
52
52
self .assertFalse (final_config ["mdx_configs" ]["toc" ]["permalink" ])
53
53
self .assertTrue ("mdx_truly_sane_lists" in final_config ["markdown_extensions" ])
54
54
55
55
def test_theme_overrides_removed_when_name_is_not_material (self ):
56
56
# we want to force the theme mkdocs to this test
57
- self .mkdocs_yaml_config ["theme" ] = Theme (name = "mkdocs" )
58
- self .mkdocs_yaml_config ["theme" ]["features" ] = ["navigation.sections" ]
59
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
57
+ self .techdocscore . config ["theme" ] = Theme (name = "mkdocs" )
58
+ self .techdocscore . config ["theme" ]["features" ] = ["navigation.sections" ]
59
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
60
60
self .assertFalse ("navigation.sections" in final_config ["theme" ]["features" ])
61
61
62
62
def test_theme_overrides_when_name_is_material (self ):
63
- self .mkdocs_yaml_config ["theme" ] = Theme (name = TECHDOCS_DEFAULT_THEME )
64
- self .mkdocs_yaml_config ["theme" ]["features" ] = ["navigation.sections" ]
65
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
63
+ self .techdocscore . config ["theme" ] = Theme (name = TECHDOCS_DEFAULT_THEME )
64
+ self .techdocscore . config ["theme" ]["features" ] = ["navigation.sections" ]
65
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
66
66
self .assertTrue ("navigation.sections" in final_config ["theme" ]["features" ])
67
67
68
68
def test_theme_overrides_techdocs_metadata (self ):
69
- self .mkdocs_yaml_config ["theme" ] = Theme (
69
+ self .techdocscore . config ["theme" ] = Theme (
70
70
name = TECHDOCS_DEFAULT_THEME , static_templates = ["my_static_temples" ]
71
71
)
72
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
72
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
73
73
self .assertTrue ("my_static_temples" in final_config ["theme" ].static_templates )
74
74
self .assertTrue (
75
75
"techdocs_metadata.json" in final_config ["theme" ].static_templates
76
76
)
77
77
78
78
def test_theme_overrides_dirs (self ):
79
79
custom_theme_dir = "/tmp/my_custom_theme_dir"
80
- self .mkdocs_yaml_config ["theme" ] = Theme (name = TECHDOCS_DEFAULT_THEME )
81
- self .mkdocs_yaml_config ["theme" ].dirs .append (custom_theme_dir )
82
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
80
+ self .techdocscore . config ["theme" ] = Theme (name = TECHDOCS_DEFAULT_THEME )
81
+ self .techdocscore . config ["theme" ].dirs .append (custom_theme_dir )
82
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
83
83
self .assertTrue (custom_theme_dir in final_config ["theme" ].dirs )
84
84
self .assertTrue (
85
85
self .techdocscore .tmp_dir_techdocs_theme .name in final_config ["theme" ].dirs
86
86
)
87
87
88
88
def test_template_renders__multiline_value_as_valid_json (self ):
89
- self .techdocscore .on_config (self .mkdocs_yaml_config )
89
+ self .techdocscore .on_config (self .techdocscore . config )
90
90
env = Environment (
91
91
loader = PackageLoader (
92
92
"techdocs_core" , self .techdocscore .tmp_dir_techdocs_theme .name
@@ -103,40 +103,35 @@ def test_template_renders__multiline_value_as_valid_json(self):
103
103
self .assertEqual (config , as_json )
104
104
105
105
def test_restrict_snippet_base_path (self ):
106
- self .mkdocs_yaml_config ["mdx_configs" ] = {
106
+ self .techdocscore . config ["mdx_configs" ] = {
107
107
"pymdownx.snippets" : {"restrict_base_path" : False }
108
108
}
109
109
110
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
110
+ final_config = self .techdocscore .on_config (self .techdocscore . config )
111
111
112
112
self .assertEqual (
113
113
final_config ["mdx_configs" ]["pymdownx.snippets" ]["restrict_base_path" ],
114
114
True ,
115
115
)
116
116
117
117
def test_material_search (self ):
118
- self .plugin_collection ["techdocs-core" ].load_config (
119
- {"use_material_search" : True }
120
- )
121
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
118
+ self .techdocscore .config ["use_material_search" ] = True
119
+ final_config = self .techdocscore .on_config (self .techdocscore .config )
122
120
123
121
self .assertEqual (
124
122
final_config ["plugins" ]["search" ].__module__ ,
125
123
"material.plugins.search.plugin" ,
126
124
)
127
125
128
126
def test_default_search (self ):
129
- self .plugin_collection ["techdocs-core" ].load_config ({})
130
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
127
+ final_config = self .techdocscore .on_config (self .techdocscore .config )
131
128
self .assertEqual (
132
129
final_config ["plugins" ]["search" ].__module__ , "mkdocs.contrib.search"
133
130
)
134
131
135
132
def test_pymdownx_blocks (self ):
136
- self .plugin_collection ["techdocs-core" ].load_config (
137
- {"use_pymdownx_blocks" : True }
138
- )
139
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
133
+ self .techdocscore .config ["use_pymdownx_blocks" ] = True
134
+ final_config = self .techdocscore .on_config (self .techdocscore .config )
140
135
141
136
self .assertTrue (
142
137
"pymdownx.blocks.admonition" in final_config ["markdown_extensions" ]
@@ -160,8 +155,7 @@ def test_pymdownx_blocks(self):
160
155
self .assertFalse ("pymdownx.tabbed" in final_config ["mdx_configs" ])
161
156
162
157
def test_default_pymdownx (self ):
163
- self .plugin_collection ["techdocs-core" ].load_config ({})
164
- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
158
+ final_config = self .techdocscore .on_config (self .techdocscore .config )
165
159
166
160
self .assertFalse (
167
161
"pymdownx.blocks.admonition" in final_config ["markdown_extensions" ]
0 commit comments