def test_explicit_canonical(self): with mock.patch('os.environ', {docs_version_var: '1.0'}): p = mkdocs_plugin.MikePlugin() p.config = {'canonical_version': 'latest'} config = {'site_url': 'https://example.com/'} p.on_config(config) self.assertEqual(config['site_url'], 'https://example.com/latest') with mock.patch('os.environ', {docs_version_var: '1.0'}): p = mkdocs_plugin.MikePlugin() p.config = {'canonical_version': ''} config = {'site_url': 'https://example.com/'} p.on_config(config) self.assertEqual(config['site_url'], 'https://example.com/')
def test_no_version(self): with mock.patch('os.environ', {}): p = mkdocs_plugin.MikePlugin() p.config = {'canonical_version': None} config = {'site_url': 'https://example.com/'} p.on_config(config) self.assertEqual(config['site_url'], 'https://example.com/')
def test_no_site_url(self): with mock.patch('os.environ', {docs_version_var: '1.0'}): p = mkdocs_plugin.MikePlugin() p.config = {'canonical_version': None} config = {'site_url': ''} p.on_config(config) self.assertEqual(config['site_url'], '')
def make_plugin(self, version_selector=True): p = mkdocs_plugin.MikePlugin() p.config = { 'version_selector': version_selector, 'css_dir': 'css', 'javascript_dir': 'js' } return p