def test_readSQLcase2(self): # 流程的相关接口 sql = "SELECT id, webfindmethod, webevelement, weboptmethod, webtestdata, webassertdata, `webtestresult` from webtest_webcasestep where webtest_webcasestep.Webcase_id = 2 ORDER BY id ASC" mysql=function.mysql() info = mysql.exe_cute(sql) for ii in info: case_list = [] case_list.append(ii) webtestcase(case_list, self) mysql.conect_close()
def caseWriteResult(case_id, result): result = result.encode('utf-8') now = time.strftime("%Y-%m-%d %H:%M:%S") sql = "UPDATE apitest_apitest set apitest_apitest.apitestresult=%s,apitest_apitest.create_time=%s where apitest_apitest.id = % s; " param = (result, now, case_id) print('api autotest result is ' + result.decode()) mysql = function.mysql() mysql.exe_cute(sql, param) mysql.conect_close()
def test_readSQLcase(self): sql = "SELECT id,`apiname`,apiurl,apimethod,apiparamvalue,apiresult,`apistatus` from apitest_apistep where apitest_apistep.Apitest_id = 1 " mysql = function.mysql() mysql.exe_cute(sql) info = mysql.result for ii in info: case_list = [] case_list.append(ii) # CredentialId() interfaceTest(case_list) mysql.conect_close()
def test(test_id): sql = "SELECT id,`apiname`,apiurl,apimethod,apiparamvalue,apiresult ,`apistatus` FROM apitest_apis where apitest_apis.id=" + str( test_id) + "; " mysql = function.mysql() mysql.exe_cute(sql) info = mysql.result for ii in info: case_list = [] case_list.append(ii) # CredentialId() interfaceTest(case_list) mysql.conect_close()
def test_report(request): username = request.session.get('user', '') apis_list = Apis.objects.all() apis_count = Apis.objects.all().count() # 统计接口数 mysql=function.mysql() cursor=mysql.cursor sql1 = 'SELECT count(id) FROM apitest_apis WHERE apitest_apis.apistatus=1' aa = cursor.execute(sql1) apis_pass_count = [row[0] for row in cursor.fetchmany(aa)][0] sql2 = 'SELECT count(id) FROM apitest_apis WHERE apitest_apis.apistatus=0' bb = cursor.execute(sql2) apis_fail_count = [row[0] for row in cursor.fetchmany(bb)][0] mysql.conect_close() return render(request, "report.html", {"user": username, "apiss": apis_list, "apiscounts": apis_count, "apis_pass_counts": apis_pass_count, "apis_fail_counts": apis_fail_count}) # 把值赋给apiscounts
def writeBug(bug_id, interface_name, request, response, res_check): interface_name = interface_name.encode('utf-8') res_check = res_check.encode('utf-8') request = request.encode('utf-8') now = time.strftime("%Y-%m-%d %H:%M:%S") bugname = str(bug_id) + '_' + interface_name.decode() + '_出错了' bugdetail = '[请求数据]<br />' + request.decode( ) + '<br/>' + '[预期结果] < br / > ' + res_check.decode( ) + ' < br / > ' + ' < br / > ' + '[响应数据] < br / > ' + ' < br / > ' + response.decode( ) print(bugdetail) sql = "INSERT INTO `bug_bug` (`bugname`,`bugdetail`,`bugstatus`,`buglevel`, `bugcreater`,`bugassign`, `created_time`, `Product_id`) VALUES ('%s', '%s', '1', '1', '邹辉', '邹辉', '%s','2');" % ( bugname, pymysql.escape_string(bugdetail), now) mysql = function.mysql() mysql.exe_cute(sql) mysql.conect_close()
from django.test import TestCase # Create your tests here. from MainWebProject import function sql = "SELECT id,`apiname`,apiurl,apimethod,apiparamvalue,apiresult,`apistatus` from apitest_apistep where apitest_apistep.Apitest_id = 1 " mysql=function.mysql() mysql.exe_cute(sql) mysql.conect_close() a=mysql.result print(a)