@@ -16,77 +16,77 @@ class DummyTechDocsCorePlugin(plugins.BasePlugin):
1616 pass
1717
1818
19- class TestTechDocsCoreConfig (unittest .TestCase ):
19+ class TestTechDocsCore (unittest .TestCase ):
2020 def setUp (self ):
21- self .techdocscore = TechDocsCore ()
2221 self .plugin_collection = plugins .PluginCollection ()
2322 plugin = DummyTechDocsCorePlugin ()
2423 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+ )
2828
2929 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 )
3131 self .assertTrue ("techdocs-core" not in final_config ["plugins" ])
3232
3333 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 )
3939 self .assertTrue ("toc" in final_config ["mdx_configs" ])
4040 self .assertTrue ("permalink" in final_config ["mdx_configs" ]["toc" ])
4141 self .assertTrue ("toc_depth" in final_config ["mdx_configs" ]["toc" ])
4242 self .assertTrue ("mdx_truly_sane_lists" in final_config ["markdown_extensions" ])
4343
4444 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 )
5050 self .assertTrue ("toc" in final_config ["mdx_configs" ])
5151 self .assertTrue ("permalink" in final_config ["mdx_configs" ]["toc" ])
5252 self .assertFalse (final_config ["mdx_configs" ]["toc" ]["permalink" ])
5353 self .assertTrue ("mdx_truly_sane_lists" in final_config ["markdown_extensions" ])
5454
5555 def test_theme_overrides_removed_when_name_is_not_material (self ):
5656 # 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 )
6060 self .assertFalse ("navigation.sections" in final_config ["theme" ]["features" ])
6161
6262 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 )
6666 self .assertTrue ("navigation.sections" in final_config ["theme" ]["features" ])
6767
6868 def test_theme_overrides_techdocs_metadata (self ):
69- self .mkdocs_yaml_config ["theme" ] = Theme (
69+ self .techdocscore . config ["theme" ] = Theme (
7070 name = TECHDOCS_DEFAULT_THEME , static_templates = ["my_static_temples" ]
7171 )
72- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
72+ final_config = self .techdocscore .on_config (self .techdocscore . config )
7373 self .assertTrue ("my_static_temples" in final_config ["theme" ].static_templates )
7474 self .assertTrue (
7575 "techdocs_metadata.json" in final_config ["theme" ].static_templates
7676 )
7777
7878 def test_theme_overrides_dirs (self ):
7979 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 )
8383 self .assertTrue (custom_theme_dir in final_config ["theme" ].dirs )
8484 self .assertTrue (
8585 self .techdocscore .tmp_dir_techdocs_theme .name in final_config ["theme" ].dirs
8686 )
8787
8888 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 )
9090 env = Environment (
9191 loader = PackageLoader (
9292 "techdocs_core" , self .techdocscore .tmp_dir_techdocs_theme .name
@@ -103,40 +103,35 @@ def test_template_renders__multiline_value_as_valid_json(self):
103103 self .assertEqual (config , as_json )
104104
105105 def test_restrict_snippet_base_path (self ):
106- self .mkdocs_yaml_config ["mdx_configs" ] = {
106+ self .techdocscore . config ["mdx_configs" ] = {
107107 "pymdownx.snippets" : {"restrict_base_path" : False }
108108 }
109109
110- final_config = self .techdocscore .on_config (self .mkdocs_yaml_config )
110+ final_config = self .techdocscore .on_config (self .techdocscore . config )
111111
112112 self .assertEqual (
113113 final_config ["mdx_configs" ]["pymdownx.snippets" ]["restrict_base_path" ],
114114 True ,
115115 )
116116
117117 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 )
122120
123121 self .assertEqual (
124122 final_config ["plugins" ]["search" ].__module__ ,
125123 "material.plugins.search.plugin" ,
126124 )
127125
128126 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 )
131128 self .assertEqual (
132129 final_config ["plugins" ]["search" ].__module__ , "mkdocs.contrib.search"
133130 )
134131
135132 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 )
140135
141136 self .assertTrue (
142137 "pymdownx.blocks.admonition" in final_config ["markdown_extensions" ]
@@ -160,8 +155,7 @@ def test_pymdownx_blocks(self):
160155 self .assertFalse ("pymdownx.tabbed" in final_config ["mdx_configs" ])
161156
162157 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 )
165159
166160 self .assertFalse (
167161 "pymdownx.blocks.admonition" in final_config ["markdown_extensions" ]
0 commit comments