Пример #1
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'], '..')
Пример #2
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'])
Пример #3
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/')
Пример #4
0
 def test_context_base_url_relative_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'], '..')
Пример #5
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'])
Пример #6
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'], '.')
Пример #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'])
Пример #8
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)