def query_testcase_list(request): '''''' collectionid=request.POST['collectionid'] moduleid=request.POST['moduleid'] tapdid=request.POST['tapdid'] keyword=request.POST['keyword'] print('moduleid:',moduleid) print('tapdid:',tapdid) print('keyword:',keyword) #query1 = 'select * from auto_ui_testcase where collection='+str(collectionid) query1 = """SELECT a.*,b.id AS module_id,b.name AS module_name,c.run_total,c.avg FROM auto_ui_testcase a LEFT JOIN auto_ui_businessmodule b ON a.business_module=b.id LEFT JOIN ( SELECT COUNT(id) AS run_total,CAST(AVG(test_duration) AS DECIMAL(10,2)) AS avg,test_name FROM uitest_tests GROUP BY test_name ) c ON a.py_name=c.test_name WHERE a.collection="""+str(collectionid) if tapdid: query1+=' and tapd_id='+tapdid if moduleid: query1+=' and business_module='+moduleid if keyword: query1+=' and py_desc like \'%'+keyword+'%\'' print('query1:',query1) conn=mysql_opr.get_connection_qadb('qateam') rsp_data=mysql_opr.select_from_mysql(conn,query1,total=0) return JsonResponse(rsp_data, safe=False)
def get(self,request): #print(request.COOKIES) menu_active='webui' query0 = 'select * from auto_ui_collection where run_env=0 and ui_sys=0' query1 = 'select * from auto_ui_collection where run_env=2 and ui_sys=0' conn=mysql_opr.get_connection_qadb('qateam') test_menus=mysql_opr.select_from_mysql(conn,query0,total=0)['data'] prd_menus=mysql_opr.select_from_mysql(conn,query1,total=0)['data'] #print(locals()) return render(request, 'yiqa_webui.html', locals())
def update_case_estimatetime(request): '''更新运行时间''' py_name=request.POST['py_name'] query1 = "SELECT AVG(test_duration) as avg FROM uitest_tests WHERE test_name='"+py_name+"'" conn=mysql_opr.get_connection_qadb('qateam') rsp_data=mysql_opr.select_from_mysql(conn,query1,total=1) if rsp_data['code']==0: if rsp_data['data']['avg']: query2="UPDATE auto_ui_testcase SET estimate_time={0} WHERE py_name='{1}'".format(rsp_data['data']['avg'], py_name) mysql_opr.query_mysql2(conn,query2,close=True) return JsonResponse(rsp_data, safe=False)
def get_collection_info(request): '''''' collectionid=request.POST['collectionid'] query0 = 'select name,run_env from auto_ui_collection where id='+str(collectionid) #query1 = 'select * from auto_ui_testcase where collection='+str(collectionid) query1 = """SELECT a.*,b.id AS module_id,b.name AS module_name,c.run_total,c.avg FROM auto_ui_testcase a LEFT JOIN auto_ui_businessmodule b ON a.business_module=b.id LEFT JOIN ( SELECT COUNT(id) AS run_total,CAST(AVG(test_duration) AS DECIMAL(10,2)) AS avg,test_name FROM uitest_tests GROUP BY test_name ) c ON a.py_name=c.test_name WHERE a.collection="""+str(collectionid) query2 = 'select id,name from auto_ui_businessmodule where collection='+str(collectionid) conn=mysql_opr.get_connection_qadb('qateam') rsp_data1=mysql_opr.select_from_mysql(conn,query0,total=1) rsp_data2=mysql_opr.select_from_mysql(conn,query1,total=0) rsp_data3=mysql_opr.select_from_mysql(conn,query2,total=0) return JsonResponse({"collection":rsp_data1['data'], "testcases":rsp_data2['data'], "testmodule":rsp_data3['data']}, safe=False)