Ejemplo n.º 1
0
    def test_create_intersphinx_data(self, mock_exists):
        mock_exists.return_Value = True

        # Test data for objects.inv file
        test_objects_inv = {
            'cpp:function': {
                'sphinx.test.function': [
                    'dummy-proj-1',
                    'dummy-version-1',
                    'test.html#epub-faq',  # file generated by ``sphinx.builders.html.StandaloneHTMLBuilder``
                    'dummy-func-name-1',
                ]
            },
            'py:function': {
                'sample.test.function': [
                    'dummy-proj-2',
                    'dummy-version-2',
                    'test.html#sample-test-func',  # file generated by ``sphinx.builders.html.StandaloneHTMLBuilder``
                    'dummy-func-name-2'
                ]
            },
            'js:function': {
                'testFunction': [
                    'dummy-proj-3',
                    'dummy-version-3',
                    'api/#test-func',  # file generated by ``sphinx.builders.dirhtml.DirectoryHTMLBuilder``
                    'dummy-func-name-3'
                ]
            }
        }

        with mock.patch('sphinx.ext.intersphinx.fetch_inventory',
                        return_value=test_objects_inv) as mock_fetch_inventory:

            _create_imported_files(
                version=self.version,
                commit='commit01',
                build=1,
                search_ranking={},
                search_ignore=[],
            )
            _create_intersphinx_data(self.version, 'commit01', 1)

            # there will be two html files,
            # `api/index.html` and `test.html`
            self.assertEqual(HTMLFile.objects.all().count(), 2)
            self.assertEqual(
                HTMLFile.objects.filter(path='test.html').count(), 1)
            self.assertEqual(
                HTMLFile.objects.filter(path='api/index.html').count(), 1)

            html_file_api = HTMLFile.objects.filter(
                path='api/index.html').first()

            self.assertEqual(SphinxDomain.objects.all().count(), 3)
            self.assertEqual(
                SphinxDomain.objects.filter(html_file=html_file_api).count(),
                1)
Ejemplo n.º 2
0
 def _manage_imported_files(self,
                            version,
                            commit,
                            build,
                            search_ranking=None):
     """Helper function for the tests to create and sync ImportedFiles."""
     search_ranking = search_ranking or {}
     _create_imported_files(
         version=version,
         commit=commit,
         build=build,
         search_ranking=search_ranking,
     )
     _sync_imported_files(version, build, set())
Ejemplo n.º 3
0
 def _manage_imported_files(self, version, commit, build):
     """Helper function for the tests to create and sync ImportedFiles."""
     _create_imported_files(version, commit, build)
     _sync_imported_files(version, build, set())