def test_sync_repository(self):
     version = self.project.versions.get(slug=LATEST)
     with mock_api(self.repo):
         sync_repository = tasks.SyncRepositoryTask()
         result = sync_repository.apply_async(
             args=(version.pk,),
         )
     self.assertTrue(result.successful())
示例#2
0
 def test_update_docs(self):
     build = get(Build, project=self.project,
                 version=self.project.versions.first())
     with mock_api(self.repo) as mapi:
         result = tasks.update_docs.delay(
             self.project.pk,
             build_pk=build.pk,
             record=False,
             intersphinx=False)
     self.assertTrue(result.successful())
 def test_update_docs_unexpected_setup_exception(self, mock_update_build, mock_setup_vcs):
     exc = Exception()
     mock_setup_vcs.side_effect = exc
     build = get(Build, project=self.project,
                 version=self.project.versions.first())
     with mock_api(self.repo) as mapi:
         result = tasks.update_docs.delay(
             self.project.pk,
             build_pk=build.pk,
             record=False,
             intersphinx=False)
     self.assertTrue(result.successful())
     mock_update_build.assert_called_once_with(state=BUILD_STATE_FINISHED)
示例#4
0
 def test_update_docs_unexpected_setup_exception(self, mock_setup_vcs):
     exc = Exception()
     mock_setup_vcs.side_effect = exc
     build = get(Build, project=self.project,
                 version=self.project.versions.first())
     with mock_api(self.repo) as mapi:
         update_docs = tasks.UpdateDocsTask()
         result = update_docs.delay(
             self.project.pk,
             build_pk=build.pk,
             record=False,
             intersphinx=False)
     self.assertTrue(result.successful())
 def test_clean_build_after_failure_in_update_docs(self, run_setup,
                                                   clean_build):
     run_setup.side_effect = Exception()
     version = self.project.versions.first()
     build = get(
         Build,
         project=self.project,
         version=version,
     )
     with mock_api(self.repo):
         result = tasks.update_docs_task.delay(
             version.pk,
             build_pk=build.pk,
             record=False,
             intersphinx=False,
         )
     clean_build.assert_called_with(version.pk)
 def test_update_docs_unexpected_build_exception(self, mock_build_docs):
     exc = Exception()
     mock_build_docs.side_effect = exc
     version = self.project.versions.first()
     build = get(
         Build,
         project=self.project,
         version=version,
     )
     with mock_api(self.repo) as mapi:
         result = tasks.update_docs_task.delay(
             version.pk,
             build_pk=build.pk,
             record=False,
             intersphinx=False,
         )
     self.assertTrue(result.successful())
示例#7
0
    def test_no_notification_on_version_locked_error(self, mock_setup_vcs, mock_send_notifications):
        mock_setup_vcs.side_effect = VersionLockedError()

        version = self.project.versions.first()

        build = get(
            Build, project=self.project,
            version=version,
        )
        with mock_api(self.repo):
            result = tasks.update_docs_task.delay(
                version.pk,
                build_pk=build.pk,
                record=False,
                intersphinx=False,
            )

        mock_send_notifications.assert_not_called()
        self.assertTrue(result.successful())
示例#8
0
    def test_build_tools_cached(self, load_config, build_run, build_tools_storage, tarfile):
        config = BuildConfigV2(
            {},
            {
                'version': 2,
                'build': {
                    'os': 'ubuntu-20.04',
                    'tools': {
                        'python': '3.10',
                        'nodejs': '16',
                        'rust': '1.55',
                        'golang': '1.17',
                    },
                },
            },
            source_file='readthedocs.yml',
        )
        config.validate()
        load_config.return_value = config

        build_tools_storage.open.return_value = b''
        build_tools_storage.exists.return_value = True
        tarfile.open.return_value.__enter__.return_value.extract_all.return_value = None

        version = self.project.versions.first()
        build = get(
            Build,
            project=self.project,
            version=version,
        )
        with mock_api(self.repo):
            result = tasks.update_docs_task.delay(
                version.pk,
                build_pk=build.pk,
                record=False,
                intersphinx=False,
            )
        self.assertTrue(result.successful())
        self.assertEqual(build_run.call_count, 13)

        python_version = settings.RTD_DOCKER_BUILD_SETTINGS['tools']['python']['3.10']
        nodejs_version = settings.RTD_DOCKER_BUILD_SETTINGS['tools']['nodejs']['16']
        rust_version = settings.RTD_DOCKER_BUILD_SETTINGS['tools']['rust']['1.55']
        golang_version = settings.RTD_DOCKER_BUILD_SETTINGS['tools']['golang']['1.17']
        self.assertEqual(
            # NOTE: casting the first argument as `list()` shows a better diff
            # explaining where the problem is
            list(build_run.call_args_list),
            [
                mock.call(
                    'mv',
                    # Use mock.ANY here because path differs when ran locally
                    # and on CircleCI
                    mock.ANY,
                    f'/home/docs/.asdf/installs/python/{python_version}',
                    record=False,
                ),
                mock.call('asdf', 'global', 'python', python_version),
                mock.call('asdf', 'reshim', 'python', record=False),
                mock.call(
                    'mv',
                    mock.ANY,
                    f'/home/docs/.asdf/installs/nodejs/{nodejs_version}',
                    record=False,
                ),
                mock.call('asdf', 'global', 'nodejs', nodejs_version),
                mock.call('asdf', 'reshim', 'nodejs', record=False),
                mock.call(
                    'mv',
                    mock.ANY,
                    f'/home/docs/.asdf/installs/rust/{rust_version}',
                    record=False,
                ),
                mock.call('asdf', 'global', 'rust', rust_version),
                mock.call('asdf', 'reshim', 'rust', record=False),
                mock.call(
                    'mv',
                    mock.ANY,
                    f'/home/docs/.asdf/installs/golang/{golang_version}',
                    record=False,
                ),
                mock.call('asdf', 'global', 'golang', golang_version),
                mock.call('asdf', 'reshim', 'golang', record=False),
                mock.ANY,
            ],
        )
示例#9
0
 def test_clean_build_after_failure_in_sync_repository(self, clean_build, run_syn_repository):
     run_syn_repository.side_effect = Exception()
     version = self.project.versions.get(slug=LATEST)
     with mock_api(self.repo):
         result = tasks.sync_repository_task.delay(version.pk)
     clean_build.assert_called_with(version.pk)
示例#10
0
 def test_clean_build_after_sync_repository(self, clean_build):
     version = self.project.versions.get(slug=LATEST)
     with mock_api(self.repo):
         result = tasks.sync_repository_task.delay(version.pk)
     self.assertTrue(result.successful())
     clean_build.assert_called_with(version.pk)
示例#11
0
 def test_sync_repository(self):
     version = self.project.versions.get(slug=LATEST)
     with mock_api(self.repo):
         sync_repository = tasks.SyncRepositoryTask()
         result = sync_repository.apply_async(args=(version.pk, ), )
     self.assertTrue(result.successful())
示例#12
0
 def test_sync_repository(self):
     version = self.project.versions.get(slug=LATEST)
     with mock_api(self.repo):
         result = tasks.sync_repository_task.delay(version.pk)
     self.assertTrue(result.successful())
示例#13
0
 def test_update_imported_doc(self):
     with mock_api(self.repo):
         result = tasks.update_imported_docs.delay(self.project.pk)
     self.assertTrue(result.successful())
示例#14
0
 def test_update_docs(self):
     with mock_api(self.repo):
         result = tasks.update_docs.delay(self.project.pk, record=False,
                                          intersphinx=False)
     self.assertTrue(result.successful())
示例#15
0
 def test_update_docs(self):
     with mock_api(self.repo):
         result = tasks.update_docs.delay(self.project.pk,
                                          record=False,
                                          intersphinx=False)
     self.assertTrue(result.successful())