def test_event_on_post_build_multi_lang(self, mock_copy_file,
                                         mock_write_file):
     plugin = search.SearchPlugin()
     plugin.load_config({'lang': ['es', 'fr']})
     config = load_config(theme='mkdocs')
     plugin.on_pre_build(config)
     plugin.on_post_build(config)
     self.assertEqual(mock_copy_file.call_count, 4)
     self.assertEqual(mock_write_file.call_count, 1)
 def test_event_on_post_build_defaults(self, mock_copy_file,
                                       mock_write_file):
     plugin = search.SearchPlugin()
     plugin.load_config({})
     config = load_config(theme='mkdocs')
     plugin.on_pre_build(config)
     plugin.on_post_build(config)
     self.assertEqual(mock_copy_file.call_count, 0)
     self.assertEqual(mock_write_file.call_count, 1)
 def test_plugin_config_min_search_length(self):
     expected = {
         'lang': ['en'],
         'separator': r'[\s\-]+',
         'min_search_length': 2,
         'prebuild_index': False,
     }
     plugin = search.SearchPlugin()
     errors, warnings = plugin.load_config({'min_search_length': 2})
     self.assertEqual(plugin.config, expected)
     self.assertEqual(errors, [])
     self.assertEqual(warnings, [])
 def test_event_on_post_build_search_index_only(self, mock_copy_file,
                                                mock_write_file):
     plugin = search.SearchPlugin()
     plugin.load_config({'lang': ['es']})
     config = load_config(theme={
         'name': 'mkdocs',
         'search_index_only': True
     }, )
     plugin.on_pre_build(config)
     plugin.on_post_build(config)
     self.assertEqual(mock_copy_file.call_count, 0)
     self.assertEqual(mock_write_file.call_count, 1)
 def test_event_on_config_defaults(self):
     plugin = search.SearchPlugin()
     plugin.load_config({})
     result = plugin.on_config(
         load_config(
             theme='mkdocs',
             extra_javascript=[],
         ), )
     self.assertFalse(result['theme']['search_index_only'])
     self.assertFalse(result['theme']['include_search_page'])
     self.assertEqual(
         result['theme'].static_templates,
         {
             '404.html',
             'sitemap.xml',
         },
     )
     self.assertEqual(len(result['theme'].dirs), 3)
     self.assertEqual(result['extra_javascript'], ['search/main.js'])
 def test_event_on_config_search_index_only(self):
     plugin = search.SearchPlugin()
     plugin.load_config({})
     config = load_config(
         theme={
             'name': 'mkdocs',
             'search_index_only': True
         },
         extra_javascript=[],
     )
     result = plugin.on_config(config)
     self.assertTrue(result['theme']['search_index_only'])
     self.assertFalse(result['theme']['include_search_page'])
     self.assertEqual(
         result['theme'].static_templates,
         {
             '404.html',
             'sitemap.xml',
         },
     )
     self.assertEqual(len(result['theme'].dirs), 2)
     self.assertEqual(len(result['extra_javascript']), 0)