コード例 #1
0
    def test_sphinx_configuration_default(
            self, run, append_conf, move, checkout_path, tmpdir,
    ):
        """Should be default to find a conf.py file."""
        checkout_path.return_value = str(tmpdir)

        apply_fs(tmpdir, {'conf.py': ''})
        self.create_config_file(tmpdir, {})
        self.project.conf_py_file = ''
        self.project.save()

        update_docs = self.get_update_docs_task()
        config = update_docs.config
        python_env = Virtualenv(
            version=self.version,
            build_env=update_docs.build_env,
            config=config,
        )
        update_docs.python_env = python_env

        update_docs.build_docs_html()

        args, kwargs = run.call_args
        assert kwargs['cwd'] == str(tmpdir)
        append_conf.assert_called_once()
        move.assert_called_once()
コード例 #2
0
    def test_python_install_requirements(self, run, checkout_path, tmpdir):
        checkout_path.return_value = str(tmpdir)
        requirements_file = 'requirements.txt'
        apply_fs(tmpdir, {requirements_file: ''})
        base_path = self.create_config_file(
            tmpdir,
            {
                'python': {
                    'install': [{
                        'requirements': requirements_file,
                    }],
                },
            },
        )

        update_docs = self.get_update_docs_task()
        config = update_docs.config

        python_env = Virtualenv(
            version=self.version,
            build_env=update_docs.build_env,
            config=config,
        )
        update_docs.python_env = python_env
        update_docs.python_env.install_requirements()

        args, kwargs = run.call_args
        full_requirements_file = str(base_path.join(requirements_file))
        install = config.python.install

        assert len(install) == 1
        assert install[0].requirements == full_requirements_file
        assert requirements_file in args
コード例 #3
0
def create_yaml(tmpdir, content):
    fs = {
        'environment.yml': '',
        'mkdocs.yml': '',
        'rtd.yml': content,
        'docs': {
            'conf.py': '',
            'requirements.txt': '',
        },
    }
    utils.apply_fs(tmpdir, fs)
    return path.join(tmpdir.strpath, 'rtd.yml')
コード例 #4
0
    def test_python_install_several_options(self, run, checkout_path, tmpdir):
        checkout_path.return_value = str(tmpdir)
        apply_fs(tmpdir, {
            'one': {},
            'two': {},
            'three.txt': '',
        })
        self.create_config_file(
            tmpdir,
            {
                'python': {
                    'install': [{
                        'path': 'one',
                        'method': 'pip',
                        'extra_requirements': ['docs'],
                    }, {
                        'path': 'two',
                        'method': 'setuptools',
                    }, {
                        'requirements': 'three.txt',
                    }],
                },
            }
        )

        update_docs = self.get_update_docs_task()
        config = update_docs.config

        python_env = Virtualenv(
            version=self.version,
            build_env=update_docs.build_env,
            config=config,
        )
        update_docs.python_env = python_env
        update_docs.python_env.install_requirements()

        install = config.python.install
        assert len(install) == 3

        args, kwargs = run.call_args_list[0]
        assert 'install' in args
        assert './one[docs]' in args
        assert install[0].method == PIP

        args, kwargs = run.call_args_list[1]
        assert 'two/setup.py' in args
        assert 'install' in args
        assert install[1].method == SETUPTOOLS

        args, kwargs = run.call_args_list[2]
        assert 'install' in args
        assert '-r' in args
        assert 'three.txt' in args
コード例 #5
0
 def create_config_file(self, tmpdir, config):
     base_path = apply_fs(tmpdir, {
         'readthedocs.yml': '',
     })
     config.setdefault('version', 2)
     config_file = path.join(str(base_path), 'readthedocs.yml')
     yaml.safe_dump(config, open(config_file, 'w'))
     return base_path
コード例 #6
0
    def test_conda_environment(self, build_failed, checkout_path, tmpdir):
        build_failed.return_value = False
        checkout_path.return_value = str(tmpdir)
        conda_file = 'environmemt.yml'
        apply_fs(tmpdir, {conda_file: ''})
        base_path = self.create_config_file(
            tmpdir,
            {
                'conda': {'environment': conda_file},
            },
        )

        update_docs = self.get_update_docs_task()
        update_docs.run_build(docker=False, record=False)

        assert update_docs.config.conda.environment == conda_file
        assert isinstance(update_docs.python_env, Conda)
コード例 #7
0
    def test_mkdocs_configuration(
        self,
        run,
        append_conf,
        move,
        checkout_path,
        tmpdir,
    ):
        checkout_path.return_value = str(tmpdir)
        apply_fs(
            tmpdir,
            {
                'mkdocs.yml': '',
                'docx': {
                    'mkdocs.yml': '',
                },
            },
        )
        self.create_config_file(
            tmpdir,
            {
                'mkdocs': {
                    'configuration': 'docx/mkdocs.yml',
                },
            },
        )
        self.project.documentation_type = 'mkdocs'
        self.project.save()

        update_docs = self.get_update_docs_task()
        config = update_docs.config
        python_env = Virtualenv(
            version=self.version,
            build_env=update_docs.build_env,
            config=config,
        )
        update_docs.python_env = python_env

        update_docs.build_docs_html()

        args, kwargs = run.call_args
        assert '--config-file' in args
        assert path.join(str(tmpdir), 'docx/mkdocs.yml') in args
        append_conf.assert_called_once()
        move.assert_called_once()
コード例 #8
0
ファイル: test_build_config.py プロジェクト: silentphp/read
def test_python_install_pipfile(tmpdir, pipfile):
    utils.apply_fs(
        tmpdir,
        {
            'another_docs': {
                'Pipfile': '',
            },
            'project': {},
            'Pipfile': '',
        },
    )
    content = '''
version: "2"
python:
  install:
    - pipfile: {}
    '''
    assertValidConfig(tmpdir, content.format(pipfile))
コード例 #9
0
    def test_conda_environment(self, build_failed, checkout_path, tmpdir):
        build_failed.return_value = False
        checkout_path.return_value = str(tmpdir)
        conda_file = 'environmemt.yml'
        apply_fs(tmpdir, {conda_file: ''})
        base_path = self.create_config_file(
            tmpdir,
            {
                'conda': {'environment': conda_file},
            },
        )

        update_docs = self.get_update_docs_task()
        update_docs.run_build(docker=False, record=False)

        conda_file = path.join(str(base_path), conda_file)
        assert update_docs.config.conda.environment == conda_file
        assert isinstance(update_docs.python_env, Conda)
コード例 #10
0
    def test_sphinx_fail_on_warning(
        self,
        run,
        append_conf,
        move,
        checkout_path,
        tmpdir,
    ):
        checkout_path.return_value = str(tmpdir)
        apply_fs(
            tmpdir,
            {
                'docx': {
                    'conf.py': '',
                },
            },
        )
        self.create_config_file(
            tmpdir,
            {
                'sphinx': {
                    'configuration': 'docx/conf.py',
                    'fail_on_warning': True,
                },
            },
        )

        update_docs = self.get_update_docs_task()
        config = update_docs.config
        python_env = Virtualenv(
            version=self.version,
            build_env=update_docs.build_env,
            config=config,
        )
        update_docs.python_env = python_env

        update_docs.build_docs_html()

        args, kwargs = run.call_args
        assert '-W' in args
        assert '--keep-going' in args
        append_conf.assert_called_once()
        move.assert_called_once()
コード例 #11
0
 def create_config_file(self, tmpdir, config):
     base_path = apply_fs(
         tmpdir, {
             'readthedocs.yml': '',
         },
     )
     config.setdefault('version', 2)
     config_file = path.join(str(base_path), 'readthedocs.yml')
     yaml.safe_dump(config, open(config_file, 'w'))
     return base_path
コード例 #12
0
    def test_mkdocs_configuration(
            self, run, append_conf, move, checkout_path, tmpdir,
    ):
        checkout_path.return_value = str(tmpdir)
        apply_fs(
            tmpdir, {
                'mkdocs.yml': '',
                'docx': {
                    'mkdocs.yml': '',
                },
            },
        )
        self.create_config_file(
            tmpdir,
            {
                'mkdocs': {
                    'configuration': 'docx/mkdocs.yml',
                },
            },
        )
        self.project.documentation_type = 'mkdocs'
        self.project.save()

        update_docs = self.get_update_docs_task()
        config = update_docs.config
        python_env = Virtualenv(
            version=self.version,
            build_env=update_docs.build_env,
            config=config,
        )
        update_docs.python_env = python_env

        update_docs.build_docs_html()

        args, kwargs = run.call_args
        assert '--config-file' in args
        assert path.join(str(tmpdir), 'docx/mkdocs.yml') in args
        append_conf.assert_called_once()
        move.assert_called_once()
コード例 #13
0
    def test_sphinx_configuration_default(self, run, append_conf, move,
                                          checkout_path, tmpdir):
        """Should be default to find a conf.py file."""
        checkout_path.return_value = str(tmpdir)

        apply_fs(tmpdir, {'conf.py': ''})
        self.create_config_file(tmpdir, {})
        self.project.conf_py_file = ''
        self.project.save()

        update_docs = self.get_update_docs_task()
        config = update_docs.config
        python_env = Virtualenv(version=self.version,
                                build_env=update_docs.build_env,
                                config=config)
        update_docs.python_env = python_env

        update_docs.build_docs_html()

        args, kwargs = run.call_args
        assert kwargs['cwd'] == str(tmpdir)
        append_conf.assert_called_once()
        move.assert_called_once()
コード例 #14
0
    def test_python_requirements(self, run, checkout_path, tmpdir):
        checkout_path.return_value = str(tmpdir)
        requirements_file = 'requirements.txt'
        apply_fs(tmpdir, {requirements_file: ''})
        base_path = self.create_config_file(
            tmpdir, {'python': {
                'requirements': requirements_file
            }})

        update_docs = self.get_update_docs_task()
        config = update_docs.config

        python_env = Virtualenv(version=self.version,
                                build_env=update_docs.build_env,
                                config=config)
        update_docs.python_env = python_env
        update_docs.python_env.install_user_requirements()

        args, kwargs = run.call_args
        requirements_file = path.join(str(base_path), requirements_file)

        assert config.python.requirements == requirements_file
        assert requirements_file in args
コード例 #15
0
    def test_sphinx_fail_on_warning(
            self, run, append_conf, move, checkout_path, tmpdir,
    ):
        checkout_path.return_value = str(tmpdir)
        apply_fs(
            tmpdir, {
                'docx': {
                    'conf.py': '',
                },
            },
        )
        self.create_config_file(
            tmpdir,
            {
                'sphinx': {
                    'configuration': 'docx/conf.py',
                    'fail_on_warning': True,
                },
            },
        )

        update_docs = self.get_update_docs_task()
        config = update_docs.config
        python_env = Virtualenv(
            version=self.version,
            build_env=update_docs.build_env,
            config=config,
        )
        update_docs.python_env = python_env

        update_docs.build_docs_html()

        args, kwargs = run.call_args
        assert '-W' in args
        append_conf.assert_called_once()
        move.assert_called_once()