Beispiel #1
0
    def test_download_successful_invalid_checksum_type(self, mock_copy,
                                                       mock_verify_size,
                                                       mock_verify_checksum,
                                                       mock_open):
        self.config.get.return_value = True

        mock_verify_checksum.side_effect = util.InvalidChecksumType()
        content_listener = listener.PackageListener(self, self.metadata_files)

        self.assertRaises(util.InvalidChecksumType,
                          content_listener.download_succeeded, self.report)

        mock_verify_checksum.assert_called_once()
        self.assertFalse(self.progress_report['content'].success.called)
Beispiel #2
0
    def _validate_checksumtype(self, unit):
        """
        Validate that the checksum type is one that we support.

        :param unit: model instance of the package that was downloaded
        :type  unit: pulp_rpm.plugins.db.models.NonMetadataPackage

        :raises verification.VerificationException: if the checksum type is not supported
        """
        if unit.checksumtype not in util.CHECKSUM_FUNCTIONS:
            error_report = {
                constants.NAME: unit.name,
                constants.ERROR_CODE: constants.ERROR_CHECKSUM_TYPE_UNKNOWN,
                constants.CHECKSUM_TYPE: unit.checksumtype,
                constants.ACCEPTED_CHECKSUM_TYPES:
                util.CHECKSUM_FUNCTIONS.keys()
            }
            self.sync.progress_report['content'].failure(unit, error_report)
            raise util.InvalidChecksumType()