'Test of when an exception occurs in backup().
In backup(), after an exception occurs in
self._backup_metadata(), we want to check the process of an
exception handler.'

def test_backup_backup_metadata_fail(self):

    volume_id = fake.VOLUME_ID
    self._create_backup_db_entry(volume_id=volume_id)
    self.flags(backup_compression_algorithm='none')
    service = nfs.NFSBackupDriver(self.ctxt)
    self.volume_file.seek(0)
    backup = objects.Backup.get_by_id(self.ctxt, fake.BACKUP_ID)
    def fake_backup_metadata(self, backup, object_meta):
        raise exception.BackupDriverException(message=_('fake'))
    self.mock_object(nfs.NFSBackupDriver, '_backup_metadata', fake_backup_metadata)
    self.assertRaises(exception.BackupDriverException, service.backup, backup, self.volume_file)
