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

def test_create_backup_with_error(self):

    vol_id = self._create_volume_db_entry(size=1)
    backup = self._create_backup_db_entry(volume_id=vol_id)
    mock_run_backup = self.mock_object(self.backup_mgr, '_run_backup')
    mock_run_backup.side_effect = FakeBackupException(str(uuid.uuid4()))
    self.assertRaises(FakeBackupException, self.backup_mgr.create_backup, self.ctxt, backup)
    vol = db.volume_get(self.ctxt, vol_id)
    self.assertEqual('available', vol['status'])
    self.assertEqual('error_backing-up', vol['previous_status'])
    backup = db.backup_get(self.ctxt, backup.id)
    self.assertEqual(fields.BackupStatus.ERROR, backup['status'])
    self.assertTrue(mock_run_backup.called)
