Beispiel #1
0
def del_case(request):
    if request.is_ajax():
        projectName = request.GET["projectName"]
        # action = request.GET["action"]
        id = request.GET["id"]
        case_data(projectName=projectName, action=2, id=id)
        return HttpResponse("del success")
Beispiel #2
0
def save_case(request):
    if request.is_ajax():
        projectName = request.GET["projectName"].strip()
        moduleName = request.GET["ModuleName"].strip()
        caseName = request.GET["CaseName"].strip()
        caseDescription = request.GET["CaseDescription"].strip()
        sql = request.GET["sql"].strip()
        protocol = request.GET["protocol"].strip()
        host = request.GET["host"].strip()
        method = request.GET["method"].strip()
        path = request.GET["path"].strip()
        headers = request.GET["headers"].strip()
        data = request.GET["data"].strip()
        replaceID = request.GET["replaceID"].strip()
        expect = request.GET["expect"].replace('"', "'").strip()
        transmitID = request.GET["TransmitID"].strip()
        transmitTargetID = request.GET["TransmitTargetID"].strip()
        checkPoint = request.GET["CheckPoint"].strip()
        if not (moduleName and caseName and protocol and host and method
                and expect):
            return HttpResponse('dataError')
        # 更新配置文件的动态数据
        if transmitID and transmitTargetID:
            current_all_data = Config(projectName).get_all()
            current_changeData = Config(projectName).get_section_all_option(
                "changeData")
            dynamicData = save_dynamic_data(expect, transmitID,
                                            transmitTargetID)
            if dynamicData:
                change_dynmaic_data = {"changeData": dynamicData}
                current_changeData.update(change_dynmaic_data)
                current_all_data.update(current_changeData)
                Config(projectName).add_dict(current_all_data)
            else:
                return HttpResponse("保存动态参数字段数量必须一致,请检查!")

        # checkPoint = request.GET["CheckPoint"].strip()

        case_data(projectName=projectName,
                  action=1,
                  sql=sql,
                  moduleName=moduleName,
                  caseName=caseName,
                  caseDescription=caseDescription,
                  protocol=protocol,
                  host=host,
                  method=method,
                  path=path,
                  headers=headers,
                  data=data,
                  file=None,
                  replaceID=replaceID,
                  expect=expect,
                  transmitID=transmitID,
                  transmitTargetID=transmitTargetID,
                  checkPoint=checkPoint,
                  author='GRUNMI',
                  editor='GRUNMI')
        return HttpResponse('success')
Beispiel #3
0
def editor_run(request):
    if request.is_ajax():
        projectname = request.GET["projectname"]
        id = request.GET["id"]
        # action = request.GET["action"]
        is_run = request.GET["is_run"]
        case_data(projectName=projectname, action=4, id=id, run=is_run)
        return HttpResponse("editor success")
Beispiel #4
0
def editor_case_page(request):
    if request.is_ajax():
        context = {}
        projectname = request.GET["projectname"]
        id = request.GET["id"]
        context["projectname"] = projectname
        context["id"] = id
        request.session['msg'] = context
        return HttpResponse('success')
    context = request.session.get('msg')
    # action=5 查询数据,返回到修改界面
    result = case_data(projectName=context['projectname'],
                       action=5,
                       id=context["id"])
    # 获取配置文件中存储的动态数据
    changeData = Config(
        context['projectname']).get_section_all_option('changeData')
    if changeData != None:
        result.update(changeData)
    return render(request, "editorCase.html", {"editor": result})