()
return jsonify({'data': _data2, 'status': 1})
返回待编辑用例信息
返回待编辑用例信息
返回待编辑用例信息
def edit_case():
    """ 返回待编辑用例信息 """
    data = request.json
    case_id = data.get('caseId')
    status = data.get('copyEditStatus')
    _data = Case.query.filter_by(id=case_id).first()
    cases = CaseData.query.filter_by(case_id=case_id).order_by(CaseData.num.asc()).all()
    case_data = []
    for case in cases:
        if status:
            case_id = ''
        else:
            case_id = case.id
        case_data.append({'num': case.num, 'name': ApiMsg.query.filter_by(id=case.api_msg_id).first().name,
                          'desc': ApiMsg.query.filter_by(id=case.api_msg_id).first().desc, 'apiMsgId': case.api_msg_id,
                          'id': case_id,
                          'status': json.loads(case.status),
                          'variableType': ApiMsg.query.filter_by(id=case.api_msg_id).first().variable_type,
                          'case_name': case.name,
                          'time': case.time,
                          'up_func': case.up_func,
                          'down_func': case.down_func,
                          'skip': case.skip,
                          'variable': json.loads(case.variable),
                          'json_variable': case.json_variable,
                          'param': json.loads(case.param),
                          'extract': json.loads(case.extract),
                          'validate': json.loads(case.validate),
                          'header': json.loads(case.header),
                          'statusCase': {'variable': json.loads(case.status_variables),
                                         'extract': json.loads(case.status_extract),
                                         'validate': json.loads(case.status_validate),
                                         'param': json.loads(case.status_param),
                                         'header': json.loads(case.status_header),
                                         },
                          })
    _data2 = {'num': _data.num, 'name': _data.name, 'desc': _data.desc, 'cases': case_data, 'setId': _data.case_set_id,
              'func_address': json.loads(_data.func_address), 'times': _data.times, 'environment': _data.environment
                , 'project_id': _data.project_id}
    if _data.variable:
        _data2['variable'] = json.loads(_data.variable)
    else:
        _data2['variable'] = []
    return jsonify({'data': _data2, 'status': 1})
def edit_case ( ) : data = request . json case_id = data . get ( 'caseId' ) status = data . get ( 'copyEditStatus' ) _data = Case . query . filter_by ( id = case_id ) . first ( ) cases = CaseData . query . filter_by ( case_id = case_id ) . order_by ( CaseData . num . asc ( ) ) . all ( ) case_data = [ ] for case in cases : if status : case_id = '' else : case_id = case . id case_data . append ( { 'num' : case . num , 'name' : ApiMsg . query . filter_by ( id = case . api_msg_id ) . first ( ) . name , 'desc' : ApiMsg . query . filter_by ( id = case . api_msg_id ) . first ( ) . desc , 'apiMsgId' : case . api_msg_id , 'id' : case_id , 'status' : json . loads ( case . status ) , 'variableType' : ApiMsg . query . filter_by ( id = case . api_msg_id ) . first ( ) . variable_type , 'case_name' : case . name , 'time' : case . time , 'up_func' : case . up_func , 'down_func' : case . down_func , 'skip' : case . skip , 'variable' : json . loads ( case . variable ) , 'json_variable' : case . json_variable , 'param' : json . loads ( case . param ) , 'extract' : json . loads ( case . extract ) , 'validate' : json . loads ( case . validate ) , 'header' : json . loads ( case . header ) , 'statusCase' : { 'variable' : json . loads ( case . status_variables ) , 'extract' : json . loads ( case . status_extract ) , 'validate' : json . loads ( case . status_validate ) , 'param' : json . loads ( case . status_param ) , 'header' : json . loads ( case . status_header ) , } , } ) _data2 = { 'num' : _data . num , 'name' : _data . name , 'desc' : _data . desc , 'cases' : case_data , 'setId' : _data . case_set_id , 'func_address' : json . loads ( _data . func_address ) , 'times' : _data . times , 'environment' : _data . environment , 'project_id' : _data . project_id } if _data . variable : _data2 [ 'variable' ] = json . loads ( _data . variable ) else : _data2 [ 'variable' ] = [ ] return jsonify ( { 'data' : _data2 , 'status' : 1 } )