Beispiel #1
0
def get_case_detail(data):
    case_id = data["case_id"]
    data_case = jsontool.convert_to_dict(
        Case.objects.all().get(case_id=case_id))
    data_api = jsontool.convert_to_dict(
        Api.objects.all().get(api_id=data_case["api_id"]))
    del (data_api['_state'])
    if data_case["depnd_api_id"] != 0:
        depnt_api = jsontool.convert_to_dict(
            DepndApi.objects.all().get(depnd_api_id=data_case["depnd_api_id"]))
        del (depnt_api['_state'])
        data_case["depnt_api"] = depnt_api
    data_case["api"] = data_api
    del (data_case['_state'])
    suite_list = list(
        CaseSuite.objects.all().filter(case_id=case_id).values_list("suite_id",
                                                                    flat=True))
    data_case["suite_list"] = suite_list
    return {"code": 1, "msg": "获取成功", "data": data_case}
Beispiel #2
0
def get_dapi_detail(data):
    """
    获取单个模块详情
    :param data:
    :return:
    """
    depnd_api_id = data['depnd_api_id']
    data = DepndApi.objects.all().get(depnd_api_id=depnd_api_id)
    data_json = jsontool.convert_to_dict(data)
    del (data_json['_state'])
    return {"code": 1, "msg": "获取成功", "data": data_json}
Beispiel #3
0
def get_module_detail(data):
    """
    获取单个模块详情
    :param data:
    :return:
    """
    module_id = data['module_id']
    data = Module.objects.all().get(module_id=module_id)
    data_json = jsontool.convert_to_dict(data)
    del (data_json['_state'])
    return {"code": 1, "msg": "获取成功", "data": data_json}
Beispiel #4
0
def get_run_info(data):
    if data["report_name"] == "":
        time1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        report_name = time1[:-3] + "测试"
    else:
        report_name = data["report_name"]
    pro_id = data["pro_id"]
    env_id = data["env_id"]
    suite_id = data["suite_id"]
    pass_num = 0
    fail_num = 0
    unrun_num = 0
    result = Result.objects.create(report_name=report_name,
                                   pro_id=pro_id,
                                   suite_id=suite_id)
    var_map = casetool.get_env_var_map(env_id)
    case_list = get_run_case_id_list(suite_id)
    start_time = int(time.time())
    for a in case_list:
        c = CaseEntity(a, var_map, result.result_id)
        try:
            c.run_front_sql()
            c.handle_depnd_param()
            c.run()
        except Exception as e:
            c.set_is_pass(False)
            c.err_msg += "\n" + str(e)
            c.setRespDefault()
            c.run_rear_sql()
        else:
            c.run_rear_sql()
            c.check_schema()
            c.check_result()
            c.check_header()
            c.check_status()
            c.set_is_pass(True)
        c.save_result()
        if c.get_is_pass() == 1:
            pass_num += 1
        elif c.get_is_pass() == 0:
            fail_num += 1
        else:
            unrun_num += 1
    end_time = int(time.time())
    result.start_time = start_time
    result.end_time = end_time
    result.pass_num = pass_num
    result.fail_num = fail_num
    result.unrun_num = unrun_num
    result.save()
    result_json = jsontool.convert_to_dict(result)
    del (result_json['_state'])
    return {"code": 1, "msg": "运行完毕", "data": result_json}
Beispiel #5
0
def get_pro_detail(data):
    """
    获取单个项目详情
    :param data:
    :return:
    """
    try:
        pro_id = data['pro_id']
        data = Project.objects.all().get(pro_id=pro_id)
        data_json = jsontool.convert_to_dict(data)
        del (data_json['_state'])
        return {"code": 1, "msg": "获取成功", "data": data_json}
    except Exception as e:
        return {
            "code": 0,
            "msg": "请求超时",
        }
Beispiel #6
0
def get_env_detail(data):
    """
    获取环境详情
    :param data:
    :return:
    """
    try:
        env_id = data['env_id']
        data = Env.objects.all().get(env_id=env_id)
        data_json = jsontool.convert_to_dict(data)
        del(data_json['_state'])
        return {
            "code": 1,
            "msg": "获取成功",
            "data": data_json
        }
    except Exception as e:
        return {
            "code": 0,
            "msg": "请求超时",
        }
Beispiel #7
0
def get_func_detail(data):
    func_id = data['func_id']
    data1 = Functions.objects.all().get(func_id=func_id)
    data_json = jsontool.convert_to_dict(data1)
    del (data_json['_state'])
    return {"code": 1, "msg": "获取成功", "data": data_json}
Beispiel #8
0
def get_check_detail(data):
    check_id = data['check_id']
    data1 = CheckModel.objects.all().get(check_id=check_id)
    data_json = jsontool.convert_to_dict(data1)
    del (data_json['_state'])
    return {"code": 1, "msg": "获取成功", "data": data_json}
Beispiel #9
0
def get_plan_detail(data):
    plan_id = data["plan_id"]
    data = RunPlan.objects.all().get(plan_id=plan_id)
    data_json = jsontool.convert_to_dict(data)
    del (data_json['_state'])
    return {"code": 1, "msg": "获取成功", "data": data_json}