'Test error handling when an error occurs during backup restore.'

def test_restore_backup_with_driver_error(self):

    vol_id = self._create_volume_db_entry(status='restoring-backup', size=1)
    backup = self._create_backup_db_entry(status=fields.BackupStatus.RESTORING, volume_id=vol_id)
    mock_run_restore = self.mock_object(self.backup_mgr, '_run_restore')
    mock_run_restore.side_effect = FakeBackupException('fake')
    self.assertRaises(FakeBackupException, self.backup_mgr.restore_backup, self.ctxt, backup, vol_id)
    vol = db.volume_get(self.ctxt, vol_id)
    self.assertEqual('error_restoring', vol['status'])
    backup = db.backup_get(self.ctxt, backup.id)
    self.assertEqual(fields.BackupStatus.AVAILABLE, backup['status'])
    self.assertTrue(mock_run_restore.called)
