Example #1
0
File: api.py Project: yinna123/IAT
def copyCase():
    user_id = session.get('user_id')
    id = request.json.get("id")
    try:
        rowData = Tree.query.filter(db.and_(Tree.id == id)).first()
        sampleData = Sample.query.filter_by(pid=id).first()
        data = Tree(rowData.project_id, rowData.pid, rowData.name,
                    rowData.type, rowData.user_id, rowData.index_id)
        db.session.add(data)
        db.session.commit()
        if sampleData:
            # pid,path,method,params,asserts_type,asserts_data,extract_type,extract_key_name,extract_data,user_id,project_id
            addData = Sample(data.id, sampleData.path, sampleData.method,
                             sampleData.param_type, sampleData.params,
                             sampleData.asserts_type, sampleData.asserts_data,
                             sampleData.extract_type,
                             sampleData.extract_key_name,
                             sampleData.extract_data, user_id,
                             sampleData.project_id)
            db.session.add(addData)
            db.session.commit()
        return make_response(
            jsonify({
                'code': 0,
                'content': None,
                'msg': u'复制成功!'
            }))
    except Exception, e:
        print e
        return make_response(
            jsonify({
                'code': 10002,
                'content': None,
                'msg': u'删除失败!'
            }))
Example #2
0
File: api.py Project: yinna123/IAT
def addCase():
    user_id = session.get('user_id')
    id = request.json.get("id")
    name = request.json.get("name")
    try:
        project_id = Tree.query.filter_by(id=id).first().project_id
        index_id = Tree.query.filter(
            db.and_(Tree.project_id == project_id, )).order_by(
                db.desc(Tree.index_id)).first().index_id
        data = Tree(project_id, id, name, 2, user_id, index_id + 1)
        db.session.add(data)
        db.session.commit()
        return make_response(
            jsonify({
                'code': 0,
                'content': {
                    "id": data.id
                },
                'msg': u'新建成功!'
            }))
    except Exception, e:
        print e
        return make_response(
            jsonify({
                'code': 10002,
                'content': None,
                'msg': u'新建失败!'
            }))
Example #3
0
File: api.py Project: yinna123/IAT
def addTreeNote(project_id, pid, name, type, user_id, index_id):
    '''
  :param pid: 父节点id
  :param name: 节点名称
  :param type: 节点属性:1.目录 2.用例
  :param user_id: 用户id
  :return: 节点 id
  '''
    data = Tree(project_id, pid, name, type, user_id, index_id)
    db.session.add(data)
    db.session.commit()
    return data.id