Ejemplo n.º 1
0
 def test_context_base_url_absolute_nested_no_page(self):
     cfg = load_config(use_directory_urls=False)
     context = build.get_context(mock.Mock(),
                                 mock.Mock(),
                                 cfg,
                                 base_url='/foo/')
     self.assertEqual(context['base_url'], '/foo/')
Ejemplo n.º 2
0
 def test_context_base_url_relative_no_page(self):
     cfg = load_config(use_directory_urls=False)
     context = build.get_context(mock.Mock(),
                                 mock.Mock(),
                                 cfg,
                                 base_url='..')
     self.assertEqual(context['base_url'], '..')
Ejemplo n.º 3
0
 def test_context_base_url__absolute_no_page_use_directory_urls(self):
     cfg = load_config()
     context = build.get_context(mock.Mock(),
                                 mock.Mock(),
                                 cfg,
                                 base_url='/')
     self.assertEqual(context['base_url'], '/')
Ejemplo n.º 4
0
 def test_context_extra_css_js_no_page(self):
     cfg = load_config(extra_css=['style.css'],
                       extra_javascript=['script.js'])
     context = build.get_context(mock.Mock(),
                                 mock.Mock(),
                                 cfg,
                                 base_url='..')
     self.assertEqual(context['extra_css'], ['../style.css'])
     self.assertEqual(context['extra_javascript'], ['../script.js'])
Ejemplo n.º 5
0
 def test_context_base_url_homepage_use_directory_urls(self):
     nav_cfg = [{'Home': 'index.md'}]
     cfg = load_config(nav=nav_cfg)
     files = Files([
         File('index.md', cfg['docs_dir'], cfg['site_dir'],
              cfg['use_directory_urls']),
     ])
     nav = get_navigation(files, cfg)
     context = build.get_context(nav, files, cfg, nav.pages[0])
     self.assertEqual(context['base_url'], '.')
Ejemplo n.º 6
0
 def test_context_base_url_nested_page(self):
     nav_cfg = [{'Home': 'index.md'}, {'Nested': 'foo/bar.md'}]
     cfg = load_config(nav=nav_cfg, use_directory_urls=False)
     files = Files([
         File('index.md', cfg['docs_dir'], cfg['site_dir'],
              cfg['use_directory_urls']),
         File('foo/bar.md', cfg['docs_dir'], cfg['site_dir'],
              cfg['use_directory_urls'])
     ])
     nav = get_navigation(files, cfg)
     context = build.get_context(nav, files, cfg, nav.pages[1])
     self.assertEqual(context['base_url'], '..')
Ejemplo n.º 7
0
 def test_context_extra_css_js_from_homepage(self):
     nav_cfg = [{'Home': 'index.md'}]
     cfg = load_config(nav=nav_cfg,
                       extra_css=['style.css'],
                       extra_javascript=['script.js'],
                       use_directory_urls=False)
     files = Files([
         File('index.md', cfg['docs_dir'], cfg['site_dir'],
              cfg['use_directory_urls']),
     ])
     nav = get_navigation(files, cfg)
     context = build.get_context(nav, files, cfg, nav.pages[0])
     self.assertEqual(context['extra_css'], ['style.css'])
     self.assertEqual(context['extra_javascript'], ['script.js'])
Ejemplo n.º 8
0
 def test_context_extra_css_js_from_nested_page_use_directory_urls(self):
     nav_cfg = [{'Home': 'index.md'}, {'Nested': 'foo/bar.md'}]
     cfg = load_config(nav=nav_cfg,
                       extra_css=['style.css'],
                       extra_javascript=['script.js'])
     files = Files([
         File('index.md', cfg['docs_dir'], cfg['site_dir'],
              cfg['use_directory_urls']),
         File('foo/bar.md', cfg['docs_dir'], cfg['site_dir'],
              cfg['use_directory_urls'])
     ])
     nav = get_navigation(files, cfg)
     context = build.get_context(nav, files, cfg, nav.pages[1])
     self.assertEqual(context['extra_css'], ['../../style.css'])
     self.assertEqual(context['extra_javascript'], ['../../script.js'])
Ejemplo n.º 9
0
 def test_extra_context(self):
     cfg = load_config(extra={'a': 1})
     context = build.get_context(mock.Mock(), mock.Mock(), cfg)
     self.assertEqual(context['config']['extra']['a'], 1)