コード例 #1
0
    def setUpClass(self):
        self.config = prepare_conf()
        self.config['confluence_max_doc_depth'] = 1
        self.config['confluence_page_hierarchy'] = True

        test_dir = os.path.dirname(os.path.realpath(__file__))
        self.dataset = os.path.join(test_dir, 'datasets', 'hierarchy')
コード例 #2
0
 def setUpClass(self):
     self.config = prepare_conf()
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.dataset = os.path.join(test_dir, 'datasets', 'common')
     self.filenames = [
         'definition-lists',
     ]
コード例 #3
0
 def setUpClass(self):
     self.config = prepare_conf()
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.dataset = os.path.join(test_dir, 'datasets', 'common')
     self.template_dir = os.path.join(test_dir, 'templates')
     self.filenames = [
         'header-footer',
     ]
コード例 #4
0
 def setUpClass(self):
     self.config = prepare_conf()
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.dataset = os.path.join(test_dir, 'datasets', 'common')
     self.filenames = prepare_sphinx_filenames(self.dataset, [
         'metadata',
     ],
                                               configs=[self.config])
コード例 #5
0
 def setUpClass(self):
     self.config = prepare_conf()
     self.config['master_doc'] = 'references'
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.dataset = os.path.join(test_dir, 'datasets', 'common')
     self.filenames = [
         'references',
         'references-ref',
     ]
コード例 #6
0
 def setUpClass(self):
     self.config = prepare_conf()
     self.config['master_doc'] = 'titlefix'
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.dataset = os.path.join(test_dir, 'datasets', 'common')
     self.filenames = [
         'titlefix',
         'titlefix-child',
     ]
コード例 #7
0
 def setUpClass(self):
     self.config = prepare_conf()
     self.config['master_doc'] = 'nested-ref-contents'
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.dataset = os.path.join(test_dir, 'datasets', 'use-cases')
     self.filenames = [
         'nested-ref-contents',
         'nested-ref-external',
     ]
コード例 #8
0
    def setUpClass(self):
        # skip alignment tests pre-sphinx 2.1 as 'default' hints do not exist
        if parse_version(sphinx_version) < parse_version('2.1'):
            raise unittest.SkipTest('default hints not supported in sphinx')

        self.config = prepare_conf()
        test_dir = os.path.dirname(os.path.realpath(__file__))
        self.dataset = os.path.join(test_dir, 'datasets', 'common')
        self.filenames = [
            'alignment',
        ]
コード例 #9
0
    def setUpClass(self):
        self.config = prepare_conf()
        test_dir = os.path.dirname(os.path.realpath(__file__))
        self.dataset = os.path.join(test_dir, 'datasets', 'common')

        self.expected_header_text = [
            'section',
            'subsection',
            'toc',
            'subsubsection',
            'newsection',
        ]
コード例 #10
0
    def setUpClass(cls):
        # always prepare a dummy configuration a unit test could use
        cls.config = prepare_conf()

        # provide a reference to common directories
        lib_dir = os.path.dirname(os.path.realpath(__file__))
        tests_dir = os.path.join(lib_dir, os.pardir)
        unit_tests_dir = os.path.join(tests_dir, 'unit-tests')

        cls.assets_dir = os.path.join(unit_tests_dir, 'assets')
        cls.datasets = os.path.join(unit_tests_dir, 'datasets')
        cls.templates_dir = os.path.join(unit_tests_dir, 'templates')
コード例 #11
0
    def test_storage_sphinx_image_candidate(self):
        config = prepare_conf()

        assets_dir = os.path.join(self.test_dir, 'assets')
        sample_img = os.path.join(assets_dir, 'test.png')

        for mime_type in SUPPORTED_IMAGE_TYPES:
            ext = mimetypes.guess_extension(mime_type)

            # handle python 3.7 interpreter | image/x-ms-bmp -> image/bmp
            # https://bugs.python.org/issue22589
            if not ext and mime_type == 'image/x-ms-bmp':
                ext = mimetypes.guess_extension('image/bmp')

            self.assertIsNotNone(ext)

            pyver = 'py{}{}'.format(sys.version_info.major,
                                    sys.version_info.minor)
            doc_dir = prepare_dirs(
                postfix='-{}-docs-{}'.format(pyver, ext[1:]))
            out_dir = prepare_dirs(postfix='-{}-out-{}'.format(pyver, ext[1:]))

            # prepare documentation set
            #  - create and index document with an asterisk image extension
            #  - copies over an image which should be mapped; note that a real
            #     image is needed as the contents can be parsed through sphinx
            #     to see if its a real image before considering it to be a
            #     candidate
            os.makedirs(doc_dir)

            index_file = os.path.join(doc_dir, 'index.rst')
            with open(index_file, 'w') as f:
                f.write('.. image:: candidate.*')

            img_filename = 'candidate' + ext
            dummy_img_file = os.path.join(doc_dir, img_filename)
            shutil.copyfile(sample_img, dummy_img_file)

            # build and check
            build_sphinx(doc_dir, config=config, out_dir=out_dir)

            with parse('index', out_dir) as data:
                image = data.find('ac:image')
                self.assertIsNotNone(image)

                attachment = image.find('ri:attachment', recursive=False)
                self.assertIsNotNone(attachment)
                self.assertTrue(attachment.has_attr('ri:filename'))
                self.assertEqual(attachment['ri:filename'], img_filename)
コード例 #12
0
    def setUpClass(cls):
        enable_sphinx_info()

        # build configuration
        space_key = os.getenv(SPACE_ENV_KEY, DEFAULT_TEST_SPACE)
        cls.config = prepare_conf()
        cls.config['confluence_disable_notifications'] = True
        cls.config['confluence_page_hierarchy'] = True
        cls.config['confluence_page_generation_notice'] = True
        cls.config['confluence_parent_page'] = None
        cls.config['confluence_prev_next_buttons_location'] = 'both'
        cls.config['confluence_publish'] = True
        cls.config['confluence_server_pass'] = os.getenv(AUTH_ENV_KEY)
        cls.config['confluence_server_url'] = DEFAULT_TEST_URL
        cls.config['confluence_server_user'] = DEFAULT_TEST_USER
        cls.config['confluence_sourcelink'] = {
            'type': 'github',
            'owner': 'sphinx-contrib',
            'repo': 'confluencebuilder',
            'container': 'tests/validation-sets/',
        }
        cls.config['confluence_space_key'] = space_key
        cls.config['confluence_timeout'] = 10
        cls.config['imgmath_font_size'] = 14
        cls.config['imgmath_image_format'] = 'svg'
        cls.config['imgmath_use_preview'] = True
        cls.config['manpages_url'] = 'https://example.org/{path}'
        cls.test_desc = os.getenv(TESTDESC_ENV_KEY, DEFAULT_TEST_DESC)
        cls.test_key = os.getenv(TESTKEY_ENV_KEY, DEFAULT_TEST_KEY)
        cls.test_version = os.getenv(TESTKEY_ENV_KEY, DEFAULT_TEST_VERSION)

        # 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
        try:
            from validation_test_overrides import config_test_version
            cls.test_version = config_test_version
        except ImportError:
            pass

        # finalize
        if cls.config['confluence_space_key'].startswith('~'):
            cls.config['confluence_root_homepage'] = False
        cls.config['confluence_publish_prefix'] = ''
        cls.config['confluence_publish_postfix'] = ''
        cls.config['confluence_purge'] = False
        cls.config['confluence_sourcelink']['version'] = cls.test_version
        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 = prepare_dirs('validation-set-base')

        config = cls.config.clone()
        config['confluence_sourcelink']['container'] += 'base/'

        # inject a navdoc from the "standard" start page
        def navdocs_transform(builder, docnames):
            builder.state.register_title('_validation_next', 'Standard', None)
            docnames.append('_validation_next')
            return docnames

        config['confluence_navdocs_transform'] = navdocs_transform

        # build/publish test base page
        build_sphinx(dataset, config=config, out_dir=doc_dir)

        # finalize configuration for tests
        cls.config['confluence_parent_page'] = cls.test_key
        cls.config['confluence_purge'] = True
        cls.config['confluence_purge_from_root'] = True
        cls.config['confluence_root_homepage'] = False
コード例 #13
0
    def run(self, result=None):
        # unique configuration each run to avoid copying it in each test
        self.config = prepare_conf()

        super(TestConfluenceConfigChecks, self).run(result)
コード例 #14
0
    def setUpClass(cls):
        enable_sphinx_info()

        # build configuration
        cls.config = prepare_conf()
        cls.config['confluence_disable_notifications'] = True
        cls.config['confluence_page_hierarchy'] = True
        cls.config['confluence_parent_page'] = None
        cls.config['confluence_publish'] = True
        cls.config['confluence_space_name'] = os.getenv(
            SPACE_ENV_KEY, DEFAULT_TEST_SPACE)
        cls.config['confluence_server_pass'] = os.getenv(AUTH_ENV_KEY)
        cls.config['confluence_server_url'] = DEFAULT_TEST_URL
        cls.config['confluence_server_user'] = DEFAULT_TEST_USER
        cls.config['confluence_timeout'] = 1
        cls.config['imgmath_font_size'] = 14
        cls.config['imgmath_image_format'] = 'svg'
        cls.config['imgmath_use_preview'] = True
        cls.config['manpages_url'] = 'https://example.org/{path}'
        cls.test_desc = os.getenv(TESTDESC_ENV_KEY, DEFAULT_TEST_DESC)
        cls.test_key = os.getenv(TESTKEY_ENV_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
        if cls.config['confluence_space_name'].startswith('~'):
            cls.config['confluence_master_homepage'] = False
        else:
            cls.config['confluence_master_homepage'] = True
        cls.config['confluence_publish_prefix'] = ''
        cls.config['confluence_publish_postfix'] = ''
        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 = prepare_dirs('validation-set-base')

        # build/publish test base page
        build_sphinx(dataset, config=cls.config, out_dir=doc_dir)

        # finalize configuration for tests
        cls.config['confluence_master_homepage'] = False
        cls.config['confluence_parent_page'] = cls.test_key
        cls.config['confluence_prev_next_buttons_location'] = 'both'
        cls.config['confluence_purge'] = True
        cls.config['confluence_purge_from_master'] = True
コード例 #15
0
 def setUpClass(self):
     self.config = prepare_conf()
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.container = os.path.join(test_dir, 'datasets', 'jira')
コード例 #16
0
 def setUpClass(self):
     self.config = prepare_conf()
     test_dir = os.path.dirname(os.path.realpath(__file__))
     self.dataset = os.path.join(test_dir, 'datasets', 'shared-asset')
コード例 #17
0
 def setUpClass(self):
     self.config = prepare_conf()
     self.test_dir = os.path.dirname(os.path.realpath(__file__))
コード例 #18
0
 def setUpClass(cls):
     cls.config = prepare_conf()
     cls.test_dir = os.path.dirname(os.path.realpath(__file__))