Пример #1
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')
    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 setUpClass(cls):
        enableSphinxStatus()

        # build configuration
        cls.config = prepareConfiguration()
        cls.config['confluence_disable_notifications'] = True
        cls.config['confluence_page_hierarchy'] = True
        cls.config['confluence_parent_page'] = DEFAULT_TEST_BASE
        cls.config['confluence_publish'] = True
        cls.config['confluence_space_name'] = DEFAULT_TEST_SPACE
        cls.config['confluence_server_url'] = DEFAULT_TEST_URL
        cls.config['confluence_server_user'] = DEFAULT_TEST_USER
        cls.config['confluence_timeout'] = 1
        cls.test_desc = DEFAULT_TEST_DESC
        cls.test_key = DEFAULT_TEST_KEY

        # overrides from user
        try:
            from validation_test_overrides import config_overrides
            cls.config.update(config_overrides)
        except ImportError:
            pass
        try:
            from validation_test_overrides import config_test_desc
            cls.test_desc = config_test_desc
        except ImportError:
            pass
        try:
            from validation_test_overrides import config_test_key
            cls.test_key = config_test_key
        except ImportError:
            pass

        # finalize configuration
        cls.config['confluence_publish_prefix'] = ''
        cls.config['confluence_purge'] = False
        cls.config['rst_epilog'] = """
.. |test_key| replace:: {}
.. |test_desc| replace:: {}
""".format(cls.test_key, cls.test_desc)

        # find validate-sets base folder
        test_dir = os.path.dirname(os.path.realpath(__file__))
        cls.datasets = os.path.join(test_dir, 'validation-sets')

        # setup base structure
        dataset = os.path.join(cls.datasets, 'base')
        doc_dir, doctree_dir = prepareDirectories('validation-set-base')

        # build/publish test base page
        buildSphinx(dataset, doc_dir, doctree_dir, cls.config)

        # finalize configuration for tests
        cls.config['confluence_master_homepage'] = False
        cls.config['confluence_purge'] = True
        cls.config['confluence_purge_from_master'] = True
        if cls.test_key != DEFAULT_TEST_KEY:
            cls.config['confluence_publish_prefix'] = '{}-'.format(cls.test_key)
        cls.config['confluence_parent_page'] = cls.test_key
Пример #4
0
    def test_common(self):
        config = dict(self.config)
        config['imgmath_image_format'] = 'svg'

        dataset = os.path.join(self.datasets, 'common')
        doc_dir, doctree_dir = prepareDirectories('validation-set-common')

        buildSphinx(dataset, doc_dir, doctree_dir, config)
Пример #5
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')
    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)
Пример #7
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)
    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_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')
Пример #10
0
    def test_nonjsonresponse(self):
        config = dict(self.config)
        config['confluence_server_url'] = 'https://example.com/'
        dataset = os.path.join(self.datasets, 'base')
        doc_dir, doctree_dir = prepareDirectories('validation-set-nonjsonresponse')

        with self.assertRaises(ConfluenceBadApiError):
            buildSphinx(dataset, doc_dir, doctree_dir, config)
Пример #11
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')
Пример #12
0
 def build_document_given_dataset(self, dataset):
     config = prepareConfiguration()
     doc_dir, doctree_dir = prepareDirectories('image-star')
     buildSphinx(dataset,
                 doc_dir,
                 doctree_dir,
                 config,
                 builder='singleconfluence')
     return doc_dir
Пример #13
0
    def test_hierarchy(self):
        config = dict(self.config)
        config['confluence_max_doc_depth'] = 2
        config['confluence_page_hierarchy'] = True

        dataset = os.path.join(self.datasets, 'hierarchy')
        doc_dir, doctree_dir = prepareDirectories('validation-set-hierarchy')

        buildSphinx(dataset, doc_dir, doctree_dir, config)
    def setUpClass(self):
        self.config = prepareConfiguration()
        test_dir = os.path.dirname(os.path.realpath(__file__))
        dataset = os.path.join(test_dir, 'dataset')
        self.expected = os.path.join(test_dir, 'expected')

        doc_dir, doctree_dir = prepareDirectories('literal-markup')
        buildSphinx(dataset, doc_dir, doctree_dir, self.config)

        self.doc_dir = 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)
Пример #16
0
    def test_header_footer(self):
        config = dict(self.config)

        dataset = os.path.join(self.datasets, 'header-footer')
        doc_dir, doctree_dir = prepareDirectories('validation-set-hf')

        config['confluence_header_file'] = os.path.join(dataset, 'header.tpl')
        config['confluence_footer_file'] = os.path.join(dataset, 'footer.tpl')

        buildSphinx(dataset, doc_dir, doctree_dir, config)
    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)
Пример #18
0
    def test_contents_default(self):
        dataset = os.path.join(self.test_dir, 'dataset-contents')
        doc_dir, doctree_dir = prepareDirectories('contents-default')
        buildSphinx(dataset, doc_dir, doctree_dir, self.config)

        with parse('sub', doc_dir) as data:
            top_link = data.find('a')
            self.assertIsNotNone(top_link, 'unable to find first link tag (a)')
            self.assertEqual(top_link['href'], '#top',
                             'contents root document not a top reference')
Пример #19
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')
    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)
Пример #21
0
def process_sandbox(target_sandbox, builder=None, defines=None):
    test_dir = os.path.dirname(os.path.realpath(__file__))
    sandbox_dir = os.path.join(test_dir, target_sandbox)

    doc_dir, doctree_dir = prepareDirectories('sandbox-test')
    buildSphinx(sandbox_dir,
                doc_dir,
                doctree_dir,
                builder=builder,
                extra_config=defines,
                relax=True)
Пример #22
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')
Пример #23
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')
Пример #24
0
    def test_autodocs(self):
        config = dict(self.config)
        config['extensions'].append('sphinx.ext.autodoc')
        config['extensions'].append('sphinx.ext.autosummary')

        dataset = os.path.join(self.datasets, 'auto-ext')
        doc_dir, doctree_dir = prepareDirectories('validation-set-auto')
        sys.path.insert(0, os.path.join(dataset, 'src'))

        buildSphinx(dataset, doc_dir, doctree_dir, config)

        sys.path.pop(0)
Пример #25
0
def process_sandbox(target_sandbox, builder=None, defines=None):
    test_dir = os.path.dirname(os.path.realpath(__file__))
    base_dir = os.path.join(test_dir, os.pardir)
    sandbox_dir = os.path.join(base_dir, target_sandbox)

    container = 'sandbox-test'
    if builder:
        container += '-' + builder

    doc_dir, doctree_dir = prepareDirectories(container)
    buildSphinx(sandbox_dir, doc_dir, doctree_dir, builder=builder,
        extra_config=defines, relax=True)
Пример #26
0
    def test_singlepage_contents_numbered(self):
        dataset = os.path.join(self.test_dir, 'dataset-contents-numbered')
        doc_dir, doctree_dir = prepareDirectories('singlepage-contents-numberd')
        buildSphinx(dataset, doc_dir, doctree_dir, self.config,
            builder='singleconfluence')

        with parse('index', doc_dir) as data:
            links = data.find_all('ac:link')
            self.assertEqual(len(links), 3)
            self.assertEqual(links[0]['ac:anchor'], '1. sub')
            self.assertEqual(links[1]['ac:anchor'], '1.1. section')
            self.assertEqual(links[2]['ac:anchor'], '1.2. section')
    def setUp(self):
        config = prepareConfiguration()
        for key, value in self.specific_configs.items():
            config[key] = value

        test_dir = os.path.dirname(os.path.realpath(__file__))
        dataset = os.path.join(test_dir, 'dataset-prefix-postfix')
        self.expected = os.path.join(test_dir, 'expected-prefix-postfix')

        doc_dir, doctree_dir = prepareDirectories('prefix-postfix')
        self.doc_dir = doc_dir

        buildSphinx(dataset, doc_dir, doctree_dir, config)
Пример #28
0
    def test_standard_macro_restricted(self):
        config = dict(self.config)

        dataset = os.path.join(self.datasets, 'standard')
        doc_dir, doctree_dir = prepareDirectories('validation-set-standard-nm')

        config['confluence_adv_restricted'] = [
            'anchor', 'children', 'code', 'info', 'viewfile', 'jira'
        ]
        config['confluence_header_file'] = os.path.join(
            dataset, 'no-macro.tpl')
        config['confluence_publish_postfix'] = ' (nomacro)'

        buildSphinx(dataset, doc_dir, doctree_dir, config)
    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)
    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)