示例#1
0
    def test_render_distribution_sync_step_with_errors_with_missing_information(
            self):
        """
        Covers bugfix 1147078, tests that errors that do not have an error message or error code
        do not crash the sync.
        """
        self.prompt.render_failure_message = mock.MagicMock()

        # Incomplete error raised a KeyError
        error1 = ('mock_filename', {})

        progress_report = {
            'yum_importer': {
                'distribution': {
                    'state': constants.STATE_FAILED,
                    'error_details': [error1]
                }
            }
        }

        renderer = status.RpmStatusRenderer(self.context)

        renderer.render_distribution_sync_step(progress_report)
        expected_message = 'File: mock_filename\n'\
                           'Error Code:   None\n'\
                           'Error Message: None'

        self.prompt.render_failure_message.assert_has_calls(
            mock.call(expected_message))
示例#2
0
    def test_render_download_step_invalid_signature_error(self):
        """
        Assert correct behavior from render_download_step() when the progress report contains errors
        about packages that did not pass signature filtering.
        """
        self.prompt.render_failure_message = mock.MagicMock()
        content_report = report.ContentReport()
        model = models.RPM(name='name',
                           epoch=0,
                           version='1.0.1',
                           release='2',
                           arch='x86_64',
                           checksumtype='sha1',
                           checksum='abcd',
                           size=1024)
        error_report = {
            'count': 32,
            constants.ERROR_CODE: 'invalid_package_signature',
        }
        content_report.failure(model, error_report)
        content_report['state'] = constants.STATE_COMPLETE
        progress_report = {'yum_importer': {'content': content_report}}
        renderer = status.RpmStatusRenderer(self.context)

        renderer.render_download_step(progress_report)

        # The call above should not have failed, and the error messages asserted below should have
        # been printed for the user.
        self.assertTrue('package errors encountered' in
                        self.prompt.render_failure_message.mock_calls[0][1][0])
        self.assertTrue(
            '32 packages failed signature filter and were not imported.' in
            self.prompt.render_failure_message.mock_calls[1][1][0])
示例#3
0
    def test_render_distribution_sync_step_with_error(self):
        """
        Assert that the expected messages are passed to render_failure_message in the event of a
        failed state.
        """
        self.prompt.render_failure_message = mock.MagicMock()
        error1 = ('mock_filename', {
            'error_message': 'mock_message',
            'error_code': 'mock_code'
        })

        progress_report = {
            'yum_importer': {
                'distribution': {
                    'state': constants.STATE_FAILED,
                    'error_details': [error1]
                }
            }
        }

        renderer = status.RpmStatusRenderer(self.context)

        renderer.render_distribution_sync_step(progress_report)
        expected_message = 'File: mock_filename\n'\
                           'Error Code:   mock_code\n'\
                           'Error Message: mock_message'

        self.prompt.render_failure_message.assert_has_calls(
            mock.call(expected_message))
示例#4
0
    def test_render_download_step_checksum_type_error(self):
        """
        Assert correct behavior from render_download_step() when the progress report contains errors
        about checksum type being unknown. This asserts coverage on code that caused #1099771.

        https://bugzilla.redhat.com/show_bug.cgi?id=1099771
        """
        self.prompt.render_failure_message = mock.MagicMock()
        content_report = report.ContentReport()
        model = models.RPM('name', 0, '1.0.1', '2', 'x86_64',
                           'non_existing_checksum', 'checksum', {'size': 1024})
        error_report = {
            constants.NAME:
            model.unit_key['name'],
            constants.ERROR_CODE:
            constants.ERROR_CHECKSUM_TYPE_UNKNOWN,
            constants.CHECKSUM_TYPE:
            model.unit_key['checksumtype'],
            constants.ACCEPTED_CHECKSUM_TYPES:
            verification.CHECKSUM_FUNCTIONS.keys()
        }
        content_report.failure(model, error_report)
        content_report['state'] = constants.STATE_COMPLETE
        progress_report = {'yum_importer': {'content': content_report}}
        renderer = status.RpmStatusRenderer(self.context)

        renderer.render_download_step(progress_report)

        # The call above should not have failed, and the error messages asserted below should have
        # been printed for the user.
        self.assertTrue('package errors encountered' in
                        self.prompt.render_failure_message.mock_calls[0][1][0])
        self.assertTrue('invalid checksum type (non_existing_checksum)' in
                        self.prompt.render_failure_message.mock_calls[1][1][0])
示例#5
0
def initialize(context):
    structure.ensure_repo_structure(context.cli)
    upload_manager = _upload_manager(context)

    repo_section = structure.repo_section(context.cli)
    repo_section.add_command(repo_create_update.RpmRepoCreateCommand(context))
    repo_section.add_command(repo_create_update.RpmRepoUpdateCommand(context))
    repo_section.add_command(cudl.DeleteRepositoryCommand(context))
    repo_section.add_command(repo_list.RpmRepoListCommand(context))
    repo_section.add_command(
        RepoSearchCommand(context, constants.REPO_NOTE_RPM))

    copy_section = structure.repo_copy_section(context.cli)
    copy_section.add_command(copy_commands.RpmCopyCommand(context))
    copy_section.add_command(copy_commands.ErrataCopyCommand(context))
    copy_section.add_command(copy_commands.DistributionCopyCommand(context))
    copy_section.add_command(copy_commands.PackageGroupCopyCommand(context))
    copy_section.add_command(copy_commands.PackageCategoryCopyCommand(context))
    copy_section.add_command(
        copy_commands.PackageEnvironmentCopyCommand(context))
    copy_section.add_command(copy_commands.AllCopyCommand(context))
    copy_section.add_command(copy_commands.SrpmCopyCommand(context))
    copy_section.add_command(copy_commands.YumRepoMetadataFileCommand(context))
    copy_section.add_command(copy_commands.DrpmCopyCommand(context))

    # Disabled as per 950690. We'll likely be able to add these back once the new
    # yum importer is finished and DRPMs are properly handled.
    # copy_section.add_command(copy_commands.DrpmCopyCommand(context))

    remove_section = structure.repo_remove_section(context.cli)
    remove_section.add_command(remove.RpmRemoveCommand(context))
    remove_section.add_command(remove.SrpmRemoveCommand(context))
    remove_section.add_command(remove.DrpmRemoveCommand(context))
    remove_section.add_command(remove.ErrataRemoveCommand(context))
    remove_section.add_command(remove.PackageGroupRemoveCommand(context))
    remove_section.add_command(remove.PackageCategoryRemoveCommand(context))
    remove_section.add_command(remove.PackageEnvironmentRemoveCommand(context))
    remove_section.add_command(remove.DistributionRemoveCommand(context))
    remove_section.add_command(remove.YumMetadataFileRemoveCommand(context))

    contents_section = structure.repo_contents_section(context.cli)
    contents_section.add_command(contents.SearchRpmsCommand(context))
    contents_section.add_command(contents.SearchDrpmsCommand(context))
    contents_section.add_command(contents.SearchSrpmsCommand(context))
    contents_section.add_command(contents.SearchPackageGroupsCommand(context))
    contents_section.add_command(
        contents.SearchPackageCategoriesCommand(context))
    contents_section.add_command(
        contents.SearchPackageEnvironmentsCommand(context))
    contents_section.add_command(contents.SearchDistributionsCommand(context))
    contents_section.add_command(contents.SearchErrataCommand(context))
    contents_section.add_command(
        contents.SearchYumMetadataFileCommand(context))

    # Add the group section, all its subsections, and commands
    group_export_section = structure.repo_group_export_section(context.cli)
    renderer = PublishStepStatusRenderer(context)
    group_export_section.add_command(
        export.RpmGroupExportCommand(context, renderer))
    group_export_section.add_command(
        export.GroupExportStatusCommand(context, renderer))

    uploads_section = structure.repo_uploads_section(context.cli)
    uploads_section.add_command(
        package.CreateRpmCommand(context, upload_manager))
    uploads_section.add_command(
        package.CreateSrpmCommand(context, upload_manager))
    uploads_section.add_command(
        errata.CreateErratumCommand(context, upload_manager))
    uploads_section.add_command(
        package_group.CreatePackageGroupCommand(context, upload_manager))
    uploads_section.add_command(
        category.CreatePackageCategoryCommand(context, upload_manager))
    uploads_section.add_command(
        comps.CreateCompsCommand(context, upload_manager))
    uploads_section.add_command(
        environment.CreatePackageEnvironmentCommand(context, upload_manager))
    uploads_section.add_command(upload.ResumeCommand(context, upload_manager))
    uploads_section.add_command(upload.CancelCommand(context, upload_manager))
    uploads_section.add_command(upload.ListCommand(context, upload_manager))

    sync_section = structure.repo_sync_section(context.cli)
    renderer = status.RpmStatusRenderer(context)
    sync_section.add_command(
        sync_publish.RunSyncRepositoryCommand(context, renderer))
    sync_section.add_command(sync_publish.SyncStatusCommand(context, renderer))

    publish_section = structure.repo_publish_section(context.cli)
    renderer = PublishStepStatusRenderer(context)
    distributor_id = ids.TYPE_ID_DISTRIBUTOR_YUM
    publish_section.add_command(
        sync_publish.RunPublishRepositoryCommand(context, renderer,
                                                 distributor_id))
    publish_section.add_command(
        sync_publish.PublishStatusCommand(context, renderer))

    repo_export_section = structure.repo_export_section(context.cli)
    renderer = PublishStepStatusRenderer(context)
    repo_export_section.add_command(export.RpmExportCommand(context, renderer))
    repo_export_section.add_command(
        sync_publish.PublishStatusCommand(context,
                                          renderer,
                                          description=DESC_EXPORT_STATUS))

    sync_schedules_section = structure.repo_sync_schedules_section(context.cli)
    sync_schedules_section.add_command(
        sync_schedules.RpmCreateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.RpmUpdateScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.RpmDeleteScheduleCommand(context))
    sync_schedules_section.add_command(
        sync_schedules.RpmListScheduleCommand(context))

    sync_schedules_section.add_command(
        sync_schedules.RpmNextRunCommand(context))