def post(self): user = g.user.username parse = reqparse.RequestParser(argument_class=MyArgument) parse.add_argument("caseName", type=str, required=True, help="caseName 不能为空") parse.add_argument("caseInterfaceId", type=str, required=True, help="caseInterfaceId 不能为空") parse.add_argument("caseProjectId", type=str, required=True, help="caseProjectId 不能为空") parse.add_argument("caseDesc", type=str, default="") caseName = parse.parse_args().get("caseName") caseDesc = parse.parse_args().get("caseDesc") caseInterfaceId = parse.parse_args().get("caseInterfaceId") caseProjectId = parse.parse_args().get("caseProjectId") # 判断是否重复 Case.assertName(caseName) # 判断caseProjectId,caseInterfaceId Project.assertIdExisted(caseProjectId) Interfaces.assertIdExisted(caseInterfaceId) # 解析step caseSteps = request.json.get('caseSteps') if not caseSteps: return jsonify(dict(code=1, data="", err="caseSteps 不能为空")) caseSteps = self.__stepOpt(caseSteps=caseSteps) try: case = Case(name=caseName, desc=caseDesc, request=caseSteps, interface_id=caseInterfaceId, project_id=caseProjectId, author=user) case.save() return jsonify(dict(code=0, data=case.id, msg='ok'))
def get(self): caseId = request.args.get("caseId") if not caseId: return jsonify(dict(code=1, data="", err="caseId 不能为空")) case = Case.get(caseId) return render_template(case.pwd)
def post(self): par = CaseParseOpt() user = g.user.username caseId = request.json.get("caseId") envId = request.json.get("envId") if not caseId: return jsonify(dict(code=1, data="", err="caseId 不能为空")) env = Envs.get(envId) case = Case.get(caseId) from comments.caseGenerate import CaseGenerateOpt from suite.pwd import get_cwd caseName = case.name caseSteps = case.request # do = Runner(caseName=caseName, caseSteps=caseSteps, env=env).setParams() do = CaseGenerateOpt() do.generateCaseFile(caseInfo=case, casePath=get_cwd(), env=env) res = do.run() # status = res[0] # case.pwd = res[1] # db.session.commit() # # return jsonify(status) return "ok"
def post(self): parse = reqparse.RequestParser(argument_class=MyArgument) parse.add_argument("caseId", type=str, required=True, help="caseId 不能为空") caseId = parse.parse_args().get('caseId') try: Case.get(caseId).Delete() return jsonify(dict(code=0, data="", msg='ok')) except Exception as e: log.exception(e) db.session.rollback() return jsonify(dict(code=1, data="", err=f"错误:{str(e)}")) finally: db.session.close()
def put(self): user = g.user.username parse = reqparse.RequestParser(argument_class=MyArgument) parse.add_argument("caseId", type=int, required=True, help="caseId 不能为空") parse.add_argument("caseName", type=str, required=True, help="caseName 不能为空") parse.add_argument("caseDesc", type=str, default="", required=False) caseId = parse.parse_args().get('caseId') caseName = parse.parse_args().get("caseName") caseDesc = parse.parse_args().get("caseDesc") # 判断是否重复 Case.assertName(caseName) # 解析step caseSteps = request.json.get('caseSteps') if not caseSteps: return jsonify(dict(code=1, data="", err="caseSteps 不能为空")) try: case = Case.get(caseId) case.name = caseName case.desc = caseDesc case.request = self.__stepOpt(caseSteps) case.save() return jsonify(dict(code=0, data=case.id, msg='ok'))
def get(self): caseId = request.args.get("caseId") try: if caseId: case = [Case.get(caseId)] else:
from . import v1 from .. import auth, db log = get_log(__name__) class CaseOpt(Resource): @auth.login_required def get(self): caseId = request.args.get("caseId") try: if caseId: case = [Case.get(caseId)] else: case = Case.all() data = { "code": 0, "msg": "ok", "data": [ {"id": i.id, "status": i.status, "author": i.author, "name": i.name, "desc": i.desc, "request": json.loads( i.request), "project_id": i.project_id, "interface_id": i.interface_id} for i in case]} return jsonify(data) except Exception as e: log.exception(e) return jsonify(dict(code=1, data="", err=f"错误:{str(e)}"))