def test_api_page(): if "api_no" not in request.args: return "Need api_no" api_no = request.args["api_no"] if len(api_no) != 32: return "Bad api_no" result, api_info = control.get_api_info(api_no, g.user_role) if result is False: return api_info module_test_env = [] if api_info["basic_info"]["module_env"] is not None: module_env_s = api_info["basic_info"]["module_env"].split("|") env_no_list = [] for env_no_s in module_env_s: env_no_list.append(int(env_no_s)) result, module_test_env = control.get_test_env(g.user_role, env_no_list) if result is False: return module_test_env if g.user_role & control.role_value["api_new"] == control.role_value["api_new"]: new_right = True else: new_right = False api_info_url = api_url_prefix + "/info/" api_output_url = api_url_prefix + "/output/" status_url = status_url_prefix + "/" test_case_url = url_prefix + "/case/" api_url = api_info["basic_info"]["api_url"] url_params = re.findall("<([\w:]+)>", api_url) url_param_info = [] for param in url_params: param_sp = param.split(":") if len(param_sp) > 1: url_param_info.append({"param_type": param_sp[0], "param_name": param_sp[1], "origin_param": "<%s>" % param}) else: url_param_info.append({"param_type": "string", "param_name": param_sp[0], "origin_param": "<%s>" % param}) return rt.render("Test_API.html", api_info=api_info, api_no=api_no, status_url=status_url, url_param_info=url_param_info, module_test_env=module_test_env, test_case_url=test_case_url, api_info_url=api_info_url, new_right=new_right, api_output_url=api_output_url)
def get_test_env(): result, env_info = control.get_test_env(g.user_role) return jsonify({"status": result, "data": env_info})