'Test error handling when error occurs during backup creation.'

@mock.patch('cinder.backup.manager.BackupManager._run_backup', side_effect=FakeBackupException(str(uuid.uuid4())))
def test_create_backup_with_snapshot_error(self, mock_run_backup):

    vol_id = self._create_volume_db_entry(size=1)
    snapshot = self._create_snapshot_db_entry(status='backing-up', volume_id=vol_id)
    backup = self._create_backup_db_entry(volume_id=vol_id, snapshot_id=snapshot.id)
    self.assertRaises(FakeBackupException, self.backup_mgr.create_backup, self.ctxt, backup)
    snapshot.refresh()
    self.assertEqual('available', snapshot.status)
    backup.refresh()
    self.assertEqual(fields.BackupStatus.ERROR, backup.status)
    self.assertTrue(mock_run_backup.called)
