'Test error handling.
Test error handling when restoring a backup with a backup
with a bad status.'

def test_restore_backup_with_bad_backup_status(self):

    vol_id = self._create_volume_db_entry(status='restoring-backup', size=1)
    backup = self._create_backup_db_entry(status=fields.BackupStatus.AVAILABLE, volume_id=vol_id)
    self.assertRaises(exception.InvalidBackup, self.backup_mgr.restore_backup, self.ctxt, backup, vol_id)
    vol = db.volume_get(self.ctxt, vol_id)
    self.assertEqual('error', vol['status'])
    backup = db.backup_get(self.ctxt, backup.id)
    self.assertEqual(fields.BackupStatus.ERROR, backup['status'])
