Ejemplo n.º 1
0
    def test_build(self, mock_Popen, mock_api_versions, mock_chdir,
                   mock_apiv2_downloads):

        # subprocess mock logic

        mock_process = mock.Mock()
        process_return_dict = {'communicate.return_value': ('SOMEGITHASH', '')}
        mock_process.configure_mock(**process_return_dict)
        mock_Popen.return_value = mock_process
        mock_Popen.side_effect = build_subprocess_side_effect

        project = ProjectFactory(allow_comments=True)

        version = project.versions.all()[0]
        mock_api_versions.return_value = [version]

        mock_apiv2_downloads.get.return_value = {'downloads': "no_url_here"}

        conf_path = os.path.join(project.checkout_path(version.slug),
                                 project.conf_py_file)

        # Mock open to simulate existing conf.py file
        with mock.patch('codecs.open', mock.mock_open(), create=True):
            with fake_paths(conf_path):
                built_docs = build_docs(
                    version,
                    False,
                    False,
                    False,
                )

        builder_class = get_builder_class(project.documentation_type)
        builder = builder_class(version)
        self.assertIn(builder.sphinx_builder,
                      str(mock_Popen.call_args_list[1]))
Ejemplo n.º 2
0
    def test_build_respects_epub_flag(self, EpubBuilder_build,
                                      PdfBuilder_build, HtmlBuilder_build,
                                      mock_Popen, mock_chdir,
                                      mock_apiv2_downloads):

        # subprocess mock logic

        mock_process = mock.Mock()
        process_return_dict = {'communicate.return_value': ('SOMEGITHASH', '')}
        mock_process.configure_mock(**process_return_dict)
        mock_Popen.return_value = mock_process
        mock_Popen.side_effect = build_subprocess_side_effect

        project = ProjectFactory(enable_pdf_build=False,
                                 enable_epub_build=True)
        version = project.versions.all()[0]

        conf_path = os.path.join(project.checkout_path(version.slug),
                                 project.conf_py_file)

        # Mock open to simulate existing conf.py file
        with mock.patch('codecs.open', mock.mock_open(), create=True):
            with fake_paths(conf_path):
                built_docs = build_docs(
                    version,
                    False,
                    False,
                    False,
                )

        # The HTML and the Epub format were built.
        self.assertEqual(HtmlBuilder_build.call_count, 1)
        self.assertEqual(EpubBuilder_build.call_count, 1)
        # PDF however was disabled and therefore not built.
        self.assertEqual(PdfBuilder_build.call_count, 0)
Ejemplo n.º 3
0
    def test_build(self, mock_Popen, mock_api_versions, mock_chdir, mock_apiv2_downloads):

        # subprocess mock logic

        mock_process = mock.Mock()
        process_return_dict = {'communicate.return_value': ('SOMEGITHASH', '')}
        mock_process.configure_mock(**process_return_dict)
        mock_Popen.return_value = mock_process
        mock_Popen.side_effect = build_subprocess_side_effect

        project = ProjectFactory(allow_comments=True)

        version = project.versions.all()[0]
        mock_api_versions.return_value = [version]

        mock_apiv2_downloads.get.return_value = {'downloads': "no_url_here"}

        conf_path = os.path.join(
            project.checkout_path(version.slug),
            project.conf_py_file)

        # Mock open to simulate existing conf.py file
        with mock.patch('codecs.open', mock.mock_open(), create=True):
            with fake_paths_lookup({conf_path: True}):
                built_docs = build_docs(version,
                                        False,
                                        False,
                                        False,
                                        )

        builder_class = get_builder_class(project.documentation_type)
        builder = builder_class(version)
        self.assertIn(builder.sphinx_builder,
                      str(mock_Popen.call_args_list[1])
                      )
Ejemplo n.º 4
0
    def test_build(self, mock_Popen, mock_api_versions, mock_chdir, mock_apiv2_downloads):

        # subprocess mock logic

        mock_process = mock.Mock()
        process_return_dict = {'communicate.return_value': ('SOMEGITHASH', '')}
        mock_process.configure_mock(**process_return_dict)
        mock_Popen.return_value = mock_process
        mock_Popen.side_effect = build_subprocess_side_effect

        project = ProjectFactory(allow_comments=True)

        version = project.versions.all()[0]
        mock_api_versions.return_value = [version]

        mock_apiv2_downloads.get.return_value = {'downloads': "no_url_here"}

        original_exists = os.path.exists
        conf_path = os.path.join(project.checkout_path(version.slug), project.conf_py_file)

        def patched_exists(path):
            if path == conf_path:
                return True
            return original_exists(path)

        with mock.patch('codecs.open', mock.mock_open(), create=True):
            with mock.patch.object(os.path, 'exists', patched_exists):
                built_docs = build_docs(version,
                                        False,
                                        False,
                                        False,
                                        False,
                                        False,
                                        False,
                                        False,
                                        )

        builder = project.doc_builder()(version)
        self.assertIn(builder.sphinx_builder,
                      str(mock_Popen.call_args_list[1])
                      )
Ejemplo n.º 5
0
    def test_build_respects_epub_flag(self,
                                      EpubBuilder_build,
                                      PdfBuilder_build,
                                      HtmlBuilder_build,
                                      mock_Popen,
                                      mock_chdir,
                                      mock_apiv2_downloads):

        # subprocess mock logic

        mock_process = mock.Mock()
        process_return_dict = {'communicate.return_value': ('SOMEGITHASH', '')}
        mock_process.configure_mock(**process_return_dict)
        mock_Popen.return_value = mock_process
        mock_Popen.side_effect = build_subprocess_side_effect

        project = ProjectFactory(
            enable_pdf_build=False,
            enable_epub_build=True)
        version = project.versions.all()[0]

        conf_path = os.path.join(project.checkout_path(version.slug), project.conf_py_file)

        # Mock open to simulate existing conf.py file
        with mock.patch('codecs.open', mock.mock_open(), create=True):
            with fake_paths_lookup({conf_path: True}):
                built_docs = build_docs(version,
                                        False,
                                        False,
                                        False,
                                        )

        # The HTML and the Epub format were built.
        self.assertEqual(HtmlBuilder_build.call_count, 1)
        self.assertEqual(EpubBuilder_build.call_count, 1)
        # PDF however was disabled and therefore not built.
        self.assertEqual(PdfBuilder_build.call_count, 0)