Exemplo n.º 1
0
def getInterfaceDataForId(request):
    langDict = getLangTextDict(request)
    serviceConf = ServiceConfService.queryServiceConfSort(request)

    # 根据版本判断应该从哪个表里取数据 王吉亮添加于20180224
    if VersionService.isCurrentVersion(request):
        getDBData = MockHttpService.getInterfaceForIdToDict(request.GET.get("id"))
        interfaceIdList = getDBData['interfaceIds'].strip(",").split(',')
        interfaceList = []
        for tmpInterfaceId in interfaceIdList:
            if tmpInterfaceId.strip() != "":
                interfaceList.append(dbModelToDict(HTTP_interfaceService.getInterfaceByInterfaceId(tmpInterfaceId.strip())))
        getDBData['interfaceList'] = interfaceList
    else:
        getDBData = MockHttpService.getVersionInterfaceForIdToDict(request.GET.get("id"),request.session.get("version"))
    return HttpResponse(ApiReturn(ApiReturn.CODE_OK, langDict["web"]["httpInterfaceSuccess"], json.dumps(getDBData)).toJson())
Exemplo n.º 2
0
def operationInterface(request, context):
    langDict = getLangTextDict(request)
    context["id"] = request.GET.get("id")
    context["option"] = request.GET.get("option")
    context["addHTTPInterface"] = "current-page"
    context["title"] = "HTTP MOCK-" + request.GET.get("id")

    if not isRelease:
        context["env"] = "test"
    try:
        if VersionService.isCurrentVersion(request):
            context["dataAddBy"] = MockHttpService.getInterfaceForId(
                request.GET.get("id")).addBy
        else:
            context["dataAddBy"] = MockHttpService.getVersionInterfaceForId(
                request.GET.get("id")).addBy

    except Exception as e:

        return render(request, "permission/page_404.html")

    # 文本
    text = {}
    try:
        text["pageTitle"] = "MOCK接口"
        if context["option"] == "select":
            text["subPageTitle"] = "查看MOCK接口"
        elif context["option"] == "edit":
            text["subPageTitle"] = "编辑MOCK接口"
        elif context["option"] == "copy":
            text["subPageTitle"] = "添加MOCK接口"
    except Exception as e:
        return HttpResponse("参数错误 %s" % e)
    context["text"] = text

    context.update(getConfigs(request))
    context.update(getServiceConf(request))
    context["debugBtnCount"] = commonWebConfig.debugBtnCount
    getDebugBtnList = getDebugBtn(request)
    context.update(getDebugBtnList)
    context["serviceJson"] = json.dumps(
        ServiceConfService.queryServiceConfSort(request))
    context["importStr"] = getPythonThirdLib()

    return render(request, "mock_server/http/HTTP_interface.html", context)
Exemplo n.º 3
0
def operationTestCase(request, context):
    langDict = getLangTextDict(request)

    context["id"] = request.GET.get("id")
    context["option"] = request.GET.get("option")
    context["page"] = 1
    context["dubbo_addHTTPTestCase"] = "current-page"
    if not isRelease:
        context["env"] = "test"
    try:
        if VersionService.isCurrentVersion(request):
            context["dataAddBy"] = DubboTestcaseService.getTestCaseForId(
                request.GET.get("id")).addBy.loginName
        else:
            context[
                "dataAddBy"] = HTTP_test_caseService.getVersionTestCaseForId(
                    request.GET.get("id")).addBy.loginName

    except Exception as e:
        return HttpResponse("参数id错误 %s" % e)

    # 文本
    text = {}
    try:
        text["pageTitle"] = langDict["dubbo"]["dubboTestCasePageHeadings_%s" %
                                              context["option"]]
        text["subPageTitle"] = langDict["dubbo"]["dubboTestCasePageHeadings_%s"
                                                 % context["option"]]
    except Exception as e:
        return HttpResponse("参数错误 %s" % e)
    context["text"] = text

    context.update(ConfigServiceForDubbo.getConfigs(request))
    context.update(getServiceConf(request))
    context["debugBtnCount"] = commonWebConfig.debugBtnCount
    getDebugBtnList = ConfigServiceForDubbo.getDebugBtn(request)
    context.update(getDebugBtnList)
    context["serviceJson"] = json.dumps(
        ServiceConfService.queryServiceConfSort(request))
    context["title"] = "DUBBO业务流-" + request.GET.get("id")
    return render(request, "dubbo/testcase/testCase.html", context)
Exemplo n.º 4
0
def getTextConf(request):
    id = request.GET.get("id")
    if VersionService.isCurrentVersion(request):
        varData = dbModelToDict(global_textService.getText(id))
    else:
        varData = dbModelToDict(global_textService.getVersionText(id))

    serviceConf = ServiceConfService.queryServiceConfSort(request)
    varData["serviceConf"] = {}
    varData["serviceConf"]["common"] = substr(varData["textValue"],
                                              "[CONF=common]", "[ENDCONF]")
    for i in range(0, len(serviceConf)):
        if serviceConf[i]["serviceConfKey"] not in varData["textValue"]:
            varData["serviceConf"]["%s" %
                                   serviceConf[i]["serviceConfKey"]] = ""
            continue
        varData["serviceConf"]["%s" %
                               serviceConf[i]["serviceConfKey"]] = substr(
                                   varData["textValue"], "[CONF=%s]" %
                                   serviceConf[i]["serviceConfKey"],
                                   "[ENDCONF]")
    return HttpResponse(ApiReturn(body=varData).toJson())
Exemplo n.º 5
0
def getServiceConf(request):
    context = {}
    serviceConf = ServiceConfService.queryServiceConfSort(request)
    context["serviceCount"] = len(serviceConf)
    serviceIncludeHTTPConf = []
    # serviceList = []
    # 显示前置和后置变量的title
    for i in range(0, len(serviceConf)):
        # serviceList.append(serviceConf[i]["serviceConfKey"])
        serviceIncludeHTTPConf.append(
            HttpConfService.getServiceIncludHttpConf(
                serviceConf[i]["serviceConfKey"]))
        httpConfStrList = ""
        for j in range(0, len(serviceIncludeHTTPConf[i])):
            if j == 0:
                httpConfStrList = "包含的环境:%s" % serviceIncludeHTTPConf[i][j][
                    "alias"]
                continue
            httpConfStrList = "%s,%s" % (httpConfStrList,
                                         serviceIncludeHTTPConf[i][j]["alias"])
        serviceConf[i]["serviceIncludeHTTPConf"] = httpConfStrList
    context["service"] = serviceConf
    return context
Exemplo n.º 6
0
def getTaskData(request):
    id = request.GET.get("id")

    if VersionService.isCurrentVersion(request):
        taskDataModel = HTTP_taskService.findTaskForId(id)[0]
        taskData = dbModelToDict(taskDataModel)
        serviceConf = ServiceConfService.queryServiceConfSort(request)
        highPriorityVARS = taskData["highPriorityVARS"]
        taskData["priorityCommon"] = substr(highPriorityVARS, "[CONF=common]",
                                            "[ENDCONF]")
        taskData["confPriority"] = {}
        for i in range(0, len(serviceConf)):
            if serviceConf[i]["serviceConfKey"] not in highPriorityVARS:
                taskData["confPriority"]["priority%s" %
                                         serviceConf[i]["serviceConfKey"]] = ""
                continue
            taskData["confPriority"][
                "priority%s" % serviceConf[i]["serviceConfKey"]] = substr(
                    highPriorityVARS,
                    "[CONF=%s]" % serviceConf[i]["serviceConfKey"],
                    "[ENDCONF]")
        taskData["interfaceList"] = []
        if taskData["taskInterfaces"]:
            taskInterfaceList = taskData["taskInterfaces"].split(",")
            for i in range(0, len(taskInterfaceList)):
                try:
                    thisInterface = HTTP_interfaceService.getInterfaceForInterfaceId(
                        taskInterfaceList[i])
                    if not thisInterface:
                        continue
                    taskData["interfaceList"].append(
                        dbModelToDict(thisInterface))
                    addBy = dbModelToDict(thisInterface.addBy)
                    del addBy["id"]
                    del addBy["state"]
                    taskData["interfaceList"][i].update(addBy)
                    # print( taskData["interfaceList"][i])
                except Exception as e:
                    # print(addBy)
                    # taskData["interfaceList"][i].update(addBy)
                    taskData["interfaceList"].append('')
                    continue
        taskData["testCaseList"] = []
        if taskData["taskTestcases"]:
            taskTestCaseList = taskData["taskTestcases"].split(",")
            for i in range(0, len(taskTestCaseList)):
                try:
                    thisTestCase = HTTP_test_caseService.getTestCaseForTestCaseId(
                        taskTestCaseList[i])
                    taskData["testCaseList"].append(
                        dbModelToDict(thisTestCase))
                    addBy = dbModelToDict(thisTestCase.addBy)
                    del addBy["id"]
                    del addBy["state"]
                    taskData["testCaseList"][i].update(addBy)
                except Exception as e:
                    taskData["interfaceList"].append('')
                    continue
        return HttpResponse(
            ApiReturn(ApiReturn.CODE_OK, body=taskData).toJson())
    else:
        taskDataModel = HTTP_taskService.findVersionTaskForId(
            id, VersionService.getVersionName(request))[0]
        taskData = dbModelToDict(taskDataModel)
        serviceConf = ServiceConfService.queryServiceConfSort(request)
        highPriorityVARS = taskData["highPriorityVARS"]
        taskData["priorityCommon"] = substr(highPriorityVARS, "[CONF=common]",
                                            "[ENDCONF]")
        taskData["confPriority"] = {}
        for i in range(0, len(serviceConf)):
            if serviceConf[i]["serviceConfKey"] not in highPriorityVARS:
                taskData["confPriority"]["priority%s" %
                                         serviceConf[i]["serviceConfKey"]] = ""
                continue
            taskData["confPriority"][
                "priority%s" % serviceConf[i]["serviceConfKey"]] = substr(
                    highPriorityVARS,
                    "[CONF=%s]" % serviceConf[i]["serviceConfKey"],
                    "[ENDCONF]")
        taskData["interfaceList"] = []
        if taskData["taskInterfaces"]:
            taskInterfaceList = taskData["taskInterfaces"].split(",")
            for i in range(0, len(taskInterfaceList)):
                try:
                    thisInterface = HTTP_interfaceService.getVersionInterfaceForInterfaceId(
                        taskInterfaceList[i],
                        VersionService.getVersionName(request))
                    if not thisInterface:
                        continue
                    taskData["interfaceList"].append(
                        dbModelToDict(thisInterface))
                    addBy = dbModelToDict(thisInterface.addBy)
                    del addBy["id"]
                    del addBy["state"]
                    taskData["interfaceList"][i].update(addBy)
                    # print( taskData["interfaceList"][i])
                except Exception as e:
                    # print(addBy)
                    # taskData["interfaceList"][i].update(addBy)
                    taskData["interfaceList"].append('')
                    continue
        taskData["testCaseList"] = []
        if taskData["taskTestcases"]:
            taskTestCaseList = taskData["taskTestcases"].split(",")
            for i in range(0, len(taskTestCaseList)):
                try:
                    thisTestCase = HTTP_test_caseService.getVersionTestCaseForTestCaseId(
                        taskTestCaseList[i],
                        VersionService.getVersionName(request))
                    taskData["testCaseList"].append(
                        dbModelToDict(thisTestCase))
                    addBy = dbModelToDict(thisTestCase.addBy)
                    del addBy["id"]
                    del addBy["state"]
                    taskData["testCaseList"][i].update(addBy)
                except Exception as e:
                    taskData["interfaceList"].append('')
                    continue
        return HttpResponse(
            ApiReturn(ApiReturn.CODE_OK, body=taskData).toJson())
Exemplo n.º 7
0
def getServiceConf(request):
    serviceConf = ServiceConfService.queryServiceConfSort(request)
    return HttpResponse(json.dumps(serviceConf))