help/manual: small doc cleanups
[gtk-doc.git] / tests / mkhtml2.py
blobc65df80704350c210cd9b1b0f5aac485a2535411
1 # -*- python; coding: utf-8 -*-
3 # gtk-doc - GTK DocBook documentation generator.
4 # Copyright (C) 2018 Stefan Sauer
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 import logging
22 import unittest
24 from lxml import etree
26 from gtkdoc import mkhtml2
29 class TestChunking(unittest.TestCase):
31 def setUp(self):
32 logging.basicConfig(
33 level=logging.INFO,
34 format='%(asctime)s:%(filename)s:%(funcName)s:%(lineno)d:%(levelname)s:%(message)s')
36 def test_chunk_only_root_gives_single_chunk(self):
37 root = etree.XML('<book />')
38 files = mkhtml2.chunk(root, 'test')
39 self.assertEqual('book', files.name)
40 self.assertEqual(0, len(files.descendants))
42 def test_chunk_single_chapter_gives_two_chunks(self):
43 root = etree.XML('<book><chapter /></book>')
44 files = mkhtml2.chunk(root, 'test')
45 descendants = [f for f in files.descendants if f.anchor is None]
46 logging.info('descendants : %s', str(descendants))
47 self.assertEqual(1, len(descendants))
49 def test_chunk_first_sect1_is_inlined(self):
50 root = etree.XML('<book><chapter><sect1 /></chapter></book>')
51 files = mkhtml2.chunk(root, 'test')
52 descendants = [f for f in files.descendants if f.anchor is None]
53 logging.info('descendants : %s', str(descendants))
54 self.assertEqual(1, len(descendants))
56 def test_chunk_second_sect1_is_not_inlined(self):
57 root = etree.XML('<book><chapter><sect1 /><sect1 /></chapter></book>')
58 files = mkhtml2.chunk(root, 'test')
59 descendants = [f for f in files.descendants if f.anchor is None]
60 logging.info('descendants : %s', str(descendants))
61 self.assertEqual(2, len(descendants))
64 if __name__ == '__main__':
65 unittest.main()