Record test case names when run a task using API
[yardstick.git] / api / database / handlers.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from api.database import db_session
10 from api.database.models import Tasks
11
12
13 class TasksHandler(object):
14
15     def insert(self, kwargs):
16         task = Tasks(**kwargs)
17         db_session.add(task)
18         db_session.commit()
19         return task
20
21     def update_status(self, task, status):
22         task.status = status
23         db_session.commit()
24
25     def update_error(self, task, error):
26         task.error = error
27         db_session.commit()
28
29     def get_task_by_taskid(self, task_id):
30         task = Tasks.query.filter_by(task_id=task_id).first()
31         return task