Exemplo n.º 1
0
    def batch_operate(self, *args, user):
        try:
            for item in args:
                # for i in range(2,item['Sheet'])
                for n in item:
                    for i in range(2, item[n].__len__()):
                        result = test_case.query.filter_by(
                            id=item[n][i][1]).first()
                        apis = ApiMangerOperate().get_list({"type": "id"})
                        api_id = ListOperate().get_item(apis, item[n][i][4], 0)
                        if result:
                            result.case_name = item[n][i][2]
                            result.parameter = JsonOperate().parameter_to_json(
                                item[n][i][5])
                            result.result = item[n][i][6]
                            result.validation_type = item[n][i][7]
                            result.mark = item[n][i][8]
                            result.api_id = api_id
                            result.updater = user
                            result.update_time = datetime.datetime.now()
                            db.session.flush()
                        else:
                            db.session.add(
                                test_case(
                                    case_name=item[n][i][2],
                                    parameter=JsonOperate().parameter_to_json(
                                        item[n][i][5]),
                                    result=item[n][i][6],
                                    validation_type=item[n][i][7],
                                    mark=item[n][i][8],
                                    api_id=api_id,
                                    creater=user))
            db.session.commit()
            db.session.close()
            return {"message": True}

        except Exception as e:
            db.session.close()
            return {"message": str(e)}
Exemplo n.º 2
0
    def add_case(self, *args):
        global admin
        try:
            for item in args:
                if item.case_name is not None:
                    api_id = ApiMangerOperate().get_id(item.servi_name)
                    admin = test_case(
                        case_name=item.case_name,
                        parameter=JsonOperate().parameter_to_json(
                            item.parameter),
                        result=item.result,
                        validation_type=item.validation_type,
                        mark=item.mark,
                        api_id=api_id,
                        creater=item.user)
                db.session.add(admin)
            db.session.commit()
            db.session.close()
            return {"message": True}

        except Exception as e:
            db.session.close()
            return {"message": str(e)}
Exemplo n.º 3
0
                                item[n][i][5])
                            result.result = item[n][i][6]
                            result.validation_type = item[n][i][7]
                            result.mark = item[n][i][8]
                            result.api_id = api_id
                            result.updater = user
                            result.update_time = datetime.datetime.now()
                            db.session.flush()
                        else:
                            db.session.add(
                                test_case(
                                    case_name=item[n][i][2],
                                    parameter=JsonOperate().parameter_to_json(
                                        item[n][i][5]),
                                    result=item[n][i][6],
                                    validation_type=item[n][i][7],
                                    mark=item[n][i][8],
                                    api_id=api_id,
                                    creater=user))
            db.session.commit()
            db.session.close()
            return {"message": True}

        except Exception as e:
            db.session.close()
            return {"message": str(e)}


if __name__ == '__main__':
    test_case().get_all()