def test_both_prefix_and_postfix(self):
     assertExpectedWithOutput(self,
                              'index_both',
                              self.expected,
                              self.doc_dir,
                              tpn='index')
     self._check_pages_content()
    def test_toctree_hidden(self):
        dataset = os.path.join(self.test_dir, 'dataset-hidden')
        expected = os.path.join(self.test_dir, 'expected-hidden')
        doc_dir, doctree_dir = prepareDirectories('dataset-hidden')
        buildSphinx(dataset, doc_dir, doctree_dir, self.config)

        assertExpectedWithOutput(self, 'index', expected, doc_dir)
Пример #3
0
    def test_metadata(self):
        dataset = os.path.join(self.dataset_base, 'common')
        expected = os.path.join(self.test_dir, 'expected')

        buildSphinx(dataset, self.doc_dir, self.doctree_dir, self.config)
        assertExpectedWithOutput(
            self, 'metadata', expected, self.doc_dir, tpn='index')
Пример #4
0
    def test_image_ending_with_star(self):
        ''' Test how Confluence Builder resolves the image path when
        it ends with star (*).
        A temporary datasetdir is created to store::
        - image with the extension as the image type to be tested (png): copy
          of the image01.png from assets folder
        - index.rst: created on the fly using star notation
        - expected output file: expected_index.conf (created on the fly too)

        Sphinx builders finds the png as the candidate. Similar tests
        can be created for all ConfluenceBuilder.supported_image_types
        but it requires an actual image of each image type.
        '''
        image_extension = self.file_extension(self.image_file)
        self.assertIn('image/' + image_extension,
                      ConfluenceBuilder.supported_image_types)
        shutil.copyfile(
            self.image_file,
            os.path.join(self.datasetdir,
                         self.image_basename + '.' + image_extension))

        self.write_index_file(os.path.join(self.datasetdir, 'index.rst'))

        expected_outfile = os.path.join(self.datasetdir, 'expected_index.conf')
        self.write_expected_index_file(expected_outfile, image_extension)

        doc_dir = self.build_document_given_dataset(self.datasetdir)
        assertExpectedWithOutput(self,
                                 self.file_basename(expected_outfile),
                                 self.datasetdir,
                                 doc_dir,
                                 tpn='index')
 def test_code_blocks(self):
     # skip code-block tests in Sphinx v1.8.x due to regression
     #  https://github.com/sphinx-contrib/confluencebuilder/issues/148
     if parse_version(sphinx_version) < parse_version('2.0'):
         raise unittest.SkipTest('not supported in sphinx-1.8.x')
     assertExpectedWithOutput(self, 'code_blocks', self.expected,
                              self.doc_dir)
Пример #6
0
    def test_singlepage_numbered(self):
        dataset = os.path.join(self.test_dir, 'dataset-numbered')
        expected = os.path.join(self.test_dir, 'expected-numbered')
        doc_dir, doctree_dir = prepareDirectories('singlepage-numbered')
        buildSphinx(dataset, doc_dir, doctree_dir, self.config,
            builder='singleconfluence')

        assertExpectedWithOutput(self, 'index', expected, doc_dir)
Пример #7
0
 def test_alignment_default(self):
     doc_dir, doctree_dir = prepareDirectories('alignment-center')
     buildSphinx(self.dataset, doc_dir, doctree_dir, self.config)
     assertExpectedWithOutput(self,
                              'alignment-center',
                              self.expected,
                              doc_dir,
                              tpn='index')
    def test_highlights_set(self):
        config = dict(self.config)
        config['highlight_language'] = 'none'

        expected = os.path.join(self.test_dir, 'expected-hs')
        doc_dir, doctree_dir = prepareDirectories('literal-markup-hs')
        buildSphinx(self.dataset, doc_dir, doctree_dir, config)
        assertExpectedWithOutput(self, 'index', expected, doc_dir)
Пример #9
0
 def test_manpage_without_config(self):
     doc_dir, doctree_dir = prepareDirectories('manpage-noconf')
     buildSphinx(self.dataset, doc_dir, doctree_dir, self.config)
     assertExpectedWithOutput(self,
                              'manpage-noconf',
                              self.expected,
                              doc_dir,
                              tpn='index')
    def test_override_lang(self):
        config = dict(self.config)
        config['confluence_lang_transform'] = test_override_lang_method

        expected = os.path.join(self.test_dir, 'expected-ol')
        doc_dir, doctree_dir = prepareDirectories('literal-markup-ol')
        buildSphinx(self.dataset, doc_dir, doctree_dir, config)
        assertExpectedWithOutput(self, 'index', expected, doc_dir)
Пример #11
0
 def test_headings_default(self):
     doc_dir, doctree_dir = prepareDirectories('headings-default')
     buildSphinx(self.dataset, doc_dir, doctree_dir, self.config)
     assertExpectedWithOutput(self,
                              'headings-default',
                              self.expected,
                              doc_dir,
                              tpn='headings')
Пример #12
0
    def test_manpage_with_config(self):
        config = dict(self.config)
        config['manpages_url'] = 'https://manpages.example.com/{path}'

        doc_dir, doctree_dir = prepareDirectories('manpage-conf')
        buildSphinx(self.dataset, doc_dir, doctree_dir, config)
        assertExpectedWithOutput(self,
                                 'manpage-conf',
                                 self.expected,
                                 doc_dir,
                                 tpn='index')
Пример #13
0
    def test_headings_with_title(self):
        config = dict(self.config)
        config['confluence_remove_title'] = False

        doc_dir, doctree_dir = prepareDirectories('headings-with-title')
        buildSphinx(self.dataset, doc_dir, doctree_dir, config)
        assertExpectedWithOutput(self,
                                 'headings-with-title',
                                 self.expected,
                                 doc_dir,
                                 tpn='headings')
Пример #14
0
    def test_alignment_right(self):
        config = dict(self.config)
        config['confluence_default_alignment'] = 'right'

        doc_dir, doctree_dir = prepareDirectories('alignment-right')
        buildSphinx(self.dataset, doc_dir, doctree_dir, config)
        assertExpectedWithOutput(self,
                                 'alignment-right',
                                 self.expected,
                                 doc_dir,
                                 tpn='index')
Пример #15
0
    def test_headerfooter_relative(self):
        config = dict(self.config)
        config['confluence_footer_file'] = '../templates/sample-footer.tpl'
        config['confluence_header_file'] = '../templates/sample-header.tpl'

        doc_dir, doctree_dir = prepareDirectories('header-footer')
        with prepareSphinx(self.dataset, doc_dir, doctree_dir, config) as app:
            app.build(force_all=True)
            assertExpectedWithOutput(self,
                                     'header-footer',
                                     self.expected,
                                     doc_dir,
                                     tpn='header-footer')
    def test_singlepage_numbered(self):
        config = prepareConfiguration()
        test_dir = os.path.dirname(os.path.realpath(__file__))

        dataset = os.path.join(test_dir, 'dataset-numbered')
        expected = os.path.join(test_dir, 'expected-numbered')
        doc_dir, doctree_dir = prepareDirectories('singlepage-numbered')
        buildSphinx(dataset,
                    doc_dir,
                    doctree_dir,
                    config,
                    builder='singleconfluence')

        assertExpectedWithOutput(self, 'index', expected, doc_dir)
Пример #17
0
    def test_headerfooter_absolute(self):
        config = dict(self.config)
        footer_tpl = os.path.join(self.template_dir, 'sample-footer.tpl')
        header_tpl = os.path.join(self.template_dir, 'sample-header.tpl')
        config['confluence_footer_file'] = footer_tpl
        config['confluence_header_file'] = header_tpl

        doc_dir, doctree_dir = prepareDirectories('header-footer')

        with prepareSphinx(self.dataset, doc_dir, doctree_dir, config) as app:
            app.build(force_all=True)
            assertExpectedWithOutput(self,
                                     'header-footer',
                                     self.expected,
                                     doc_dir,
                                     tpn='header-footer')
    def test_toctree_default(self):
        dataset = os.path.join(self.test_dir, 'dataset')
        expected = os.path.join(self.test_dir, 'expected-def')
        doc_dir, doctree_dir = prepareDirectories('toctree-markup-def')
        buildSphinx(dataset, doc_dir, doctree_dir, self.config)

        assertExpectedWithOutput(self, 'index', expected, doc_dir)
        assertExpectedWithOutput(self, 'doca', expected, doc_dir)
        assertExpectedWithOutput(self, 'docb', expected, doc_dir)
        assertExpectedWithOutput(self, 'docc', expected, doc_dir)
    def test_toctree_child_macro(self):
        config = dict(self.config)
        config['confluence_page_hierarchy'] = True
        config['confluence_adv_hierarchy_child_macro'] = True

        dataset = os.path.join(self.test_dir, 'dataset')
        expected = os.path.join(self.test_dir, 'expected-cm')
        doc_dir, doctree_dir = prepareDirectories('toctree-markup-cm')
        buildSphinx(dataset, doc_dir, doctree_dir, config)

        assertExpectedWithOutput(self, 'index', expected, doc_dir)
        assertExpectedWithOutput(self, 'doca', expected, doc_dir)
        assertExpectedWithOutput(self, 'docb', expected, doc_dir)
        assertExpectedWithOutput(self, 'docc', expected, doc_dir)
    def test_toctree_numbered_secnumbers_depth(self):
        config = dict(self.config)
        dataset = os.path.join(self.test_dir, 'dataset-numbered-depth')
        expected = os.path.join(self.test_dir, 'expected-numbered-depth')
        doc_dir, doctree_dir = prepareDirectories('toctree-markup-numbered-depth')
        buildSphinx(dataset, doc_dir, doctree_dir, config)

        assertExpectedWithOutput(self, 'index', expected, doc_dir)
        assertExpectedWithOutput(self, 'doc1', expected, doc_dir)
        assertExpectedWithOutput(self, 'doc2', expected, doc_dir)
    def test_toctree_numbered_disable(self):
        config = dict(self.config)
        config['confluence_add_secnumbers'] = False
        dataset = os.path.join(self.test_dir, 'dataset-numbered')
        expected = os.path.join(self.test_dir, 'expected-numbered-disabled')
        doc_dir, doctree_dir = prepareDirectories('toctree-markup-numbered-disabled')
        buildSphinx(dataset, doc_dir, doctree_dir, config)

        assertExpectedWithOutput(self, 'index', expected, doc_dir)
        assertExpectedWithOutput(self, 'doc1', expected, doc_dir)
        assertExpectedWithOutput(self, 'doc2', expected, doc_dir)
    def test_max_depth(self):
        assertExpectedWithOutput(self, 'toctree', self.expected, self.doc_dir)
        assertExpectedWithOutput(self, 'toctree-doc1', self.expected,
                                 self.doc_dir)
        assertExpectedWithOutput(self, 'toctree-doc2', self.expected,
                                 self.doc_dir)
        assertExpectedWithOutput(self, 'toctree-doc3', self.expected,
                                 self.doc_dir)

        test_paths = [
            os.path.join(self.doc_dir, 'toctree-doc2a.conf'),
            os.path.join(self.doc_dir, 'toctree-doc2aa.conf'),
            os.path.join(self.doc_dir, 'toctree-doc2aaa.conf'),
            os.path.join(self.doc_dir, 'toctree-doc2b.conf'),
            os.path.join(self.doc_dir, 'toctree-doc2c.conf')
        ]
        for test_path in test_paths:
            self.assertFalse(
                os.path.exists(test_path),
                'unexpected file was generated: {}'.format(test_path))
Пример #23
0
 def _assertExpectedWithOutput(self, name, expected=None):
     expected = expected if expected else self.expected
     assertExpectedWithOutput(self, name, expected, self.doc_dir)
 def _check_pages_content(self):
     assertExpectedWithOutput(self, 'page1', self.expected, self.doc_dir)
     assertExpectedWithOutput(self, 'page2', self.expected, self.doc_dir)
     assertExpectedWithOutput(self, 'page3', self.expected, self.doc_dir)
 def test_highlights_default(self):
     expected = os.path.join(self.test_dir, 'expected-hd')
     doc_dir, doctree_dir = prepareDirectories('literal-markup-hd')
     buildSphinx(self.dataset, doc_dir, doctree_dir, self.config)
     assertExpectedWithOutput(self, 'index', expected, doc_dir)
 def test_literal_includes(self):
     assertExpectedWithOutput(self, 'literal_includes', self.expected,
                              self.doc_dir)
 def test_literal_blocks(self):
     assertExpectedWithOutput(self, 'literal_blocks', self.expected,
                              self.doc_dir)