[gtk-doc] mkhtml2: add test for nav_link generation
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] mkhtml2: add test for nav_link generation
- Date: Wed, 13 Feb 2019 19:43:52 +0000 (UTC)
commit c76b408f0590f939ca256d88dd0b22f5f9a33fcb
Author: Stefan Sauer <ensonic users sf net>
Date: Tue Feb 12 07:52:25 2019 +0100
mkhtml2: add test for nav_link generation
tests/mkhtml2.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 46 insertions(+), 4 deletions(-)
---
diff --git a/tests/mkhtml2.py b/tests/mkhtml2.py
index bf7802b..da9dd2b 100755
--- a/tests/mkhtml2.py
+++ b/tests/mkhtml2.py
@@ -108,10 +108,10 @@ class TestDataExtraction(unittest.TestCase):
class TestDevhelp(unittest.TestCase):
- def setUp(self):
- logging.basicConfig(
- level=logging.INFO,
- format='%(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s')
+ # def setUp(self):
+ # logging.basicConfig(
+ # level=logging.INFO,
+ # format='%(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s')
def chunk_db(self, xml):
root = etree.XML(xml)
@@ -143,5 +143,47 @@ class TestDevhelp(unittest.TestCase):
self.assertIn('title="test Reference Manual"', devhelp[0])
+class TestNavNodes(unittest.TestCase):
+
+ def setUp(self):
+ logging.basicConfig(
+ level=logging.INFO,
+ format='%(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s')
+
+ def chunk_db(self, xml):
+ root = etree.XML(xml)
+ files = mkhtml2.chunk(root, 'test')
+ return [f for f in PreOrderIter(files) if f.anchor is None]
+
+ def test_nav_nodes_contains_home(self):
+ files = self.chunk_db(textwrap.dedent("""\
+ <book>
+ </book>"""))
+ nav = mkhtml2.generate_nav_nodes(files, files[0])
+ self.assertEqual(1, len(nav))
+ self.assertIn('nav_home', nav)
+
+ def test_nav_nodes_contains_up_and_prev(self):
+ files = self.chunk_db(textwrap.dedent("""\
+ <book>
+ <chapter id="chap1"><title>Intro</title></chapter>
+ </book>"""))
+ nav = mkhtml2.generate_nav_nodes(files, files[1])
+ self.assertEqual(3, len(nav))
+ self.assertIn('nav_up', nav)
+ self.assertIn('nav_prev', nav)
+ self.assertNotIn('nav_next', nav)
+
+ def test_nav_nodes_contains_next(self):
+ files = self.chunk_db(textwrap.dedent("""\
+ <book>
+ <chapter id="chap1"><title>Intro</title></chapter>
+ <chapter id="chap2"><title>Content</title></chapter>
+ </book>"""))
+ nav = mkhtml2.generate_nav_nodes(files, files[1])
+ self.assertEqual(4, len(nav))
+ self.assertIn('nav_next', nav)
+
+
if __name__ == '__main__':
unittest.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]