def test_p5_findDocumentsRemarkList(self, case): '''获取拒绝的taskid''' global TestResult # 全局变量 # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] param1 = (case['Params']) headers = dict(token=getattr(GetData, "token_chushen")) headers['Content-type'] = "application/x-www-form-urlencoded" # 发起测试 if "%" in param1: # 使用占位符的方法,没法匹配多个%s projectId = getattr(GetData, "projectId") investorId = getattr(GetData, "investorId") print("projectId:{},investorId:{}".format(projectId, investorId)) param1 = param1 % ({ "projectId": projectId, "investorId": investorId }) param = param1.encode("utf-8") else: param2 = (case['Params']) param = param2.encode("utf-8") My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print("response>>>>>>>>>>>>>>>>>" + str(resp.json())) message = resp.json()["code"] if case['CaseId'] == 2: #公司初审的taskid taskId2value = resp.json()["data"]["taskId"] setattr(GetData, "taskId2", taskId2value) print('taskId2的值是>>>>>>>>>>' + taskId2value) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_o4_repeatAuditRequest(self, case): """立项审核""" # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] param1 = (case['Params']) print("param1>>>>>>>>>>>>>>>>>" + param1) headers = dict(token=getattr(GetData, "token_chenzhihong")) headers['Content-type'] = "application/x-www-form-urlencoded" # 发起测试 if "%" in param1: # 使用占位符的方法,没法匹配多个%s projectId = getattr(GetData, "projectId") projectNumber = getattr(GetData, "projectNumber") taskId = getattr(GetData, "taskId") originalInvestorId = getattr(GetData, "originalInvestorId") print( "projectId:{},projectNumber:{},taskId:{},originalInvestorId:{}" .format(projectId, projectNumber, taskId, originalInvestorId)) param1 = param1 % ({ "projectId": projectId, "projectNumber": projectNumber, "taskId": taskId, "originalInvestorId": originalInvestorId }) param = param1.encode("utf-8") else: param2 = (case['Params']) param = param2.encode("utf-8") My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print("response>>>>>>>>>>>>>>>>>" + str(resp.json())) message = resp.json()["code"] try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_findProjectinfo(self, case): """获取项目详情项目ID的校验""" global TestResult # 全局变量 # 执行测试 getattr(GetData, 'value_id') method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] param1 = (case['Params']) if "%" in param1: projectId = getattr(GetData, "projectId") print("projectId>>>>>>>>>>>>" + str(projectId)) # 占位符,给用例里面的百分号赋值projectID param1 = param1 % ({"projectId": projectId}) param = param1.encode("utf-8") else: param2 = (case['Params']) param = param2.encode("utf-8") headers = dict(token=get_token()) print(headers) # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print(resp.json()) message = resp.json()["code"] print(message) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_shouye(self, case): '''登陆首页是否跳转正确''' global TestResult # 全局变量 # global token # 执行测试 method = case['Method'] # 读取是哪个 env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] print(url) # if case['Params'].find('loanid') != -1: # param里面发现loanid # param = eval(case['Params'].replace('loanid', str(getattr(GetData, 'LOAN_ID')))) # 将param里loanid替换 # else: param = eval(case['Params']) print(type(param)) print(param) headers = dict(token=get_token()) print(headers) # 发起测试 # res = HttpRequests().http_request(method,url,param,headers,verify=False) My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print(resp.json()) # if case['sql']!=None: # loan_id = DoMysql().do_mysql(eval(case['sql'])['sql'], 1) # 从大的case字典里取出sql的字典,并通过键值对取出sql查询语句 # setattr(GetData, 'LOAN_ID', loan_id[0]) #data = resp.json() # if (data['token']): # 判断cookies是否为空 # setattr(GetData, 'token', data["token"]) message = resp.json()["code"] print(message) # print(type(message)) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_create_project(self, case): '''创建项目的所有的接口''' global TestResult # 全局变量 # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] param = (case['Params']) headers = dict(token=get_token()) headers['Content-type'] = "application/x-www-form-urlencoded" # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print(resp.json()) message = resp.json()["code"] print(message) # 把项目id放到datatree接口的参数里面 if case['CaseId'] == 4: #把projectID的值存起来 projectIdvalue = resp.json()["data"]["projectId"] setattr(GetData, "projectId", projectIdvalue) print('projectID的值是>>>>>>>>>>' + str(projectIdvalue)) #把investorId的值存起来 investorIdvalue = resp.json()["data"]["investorId"] setattr(GetData, "investorId", investorIdvalue) print('investorId的值是>>>>>>>>>>' + str(investorIdvalue)) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_case(self, case): global TestResult # 全局变量 #global token # 执行测试 method = case['Method'] url = case['Url'] # if case['Params'].find('loanid') != -1: # param里面发现loanid # param = eval(case['Params'].replace('loanid', str(getattr(GetData, 'LOAN_ID')))) # 将param里loanid替换 # else: param = eval(case['Params']) print(type(param)) print(param) headers = {"token": get_token()} print(headers) # 发起测试 # res = HttpRequests().http_request(method,url,param,headers,verify=False) My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print(resp.json()["code"]) # if case['sql']!=None: # loan_id = DoMysql().do_mysql(eval(case['sql'])['sql'], 1) # 从大的case字典里取出sql的字典,并通过键值对取出sql查询语句 # setattr(GetData, 'LOAN_ID', loan_id[0]) #data = resp.json() # if (data['token']): # 判断cookies是否为空 # setattr(GetData, 'token', data["token"]) try: self.assertEqual(eval(case['ExpectedResult']), resp.json()["code"]) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_getProjectListByStatus(self, case): """创建项目其他参数的校验""" global TestResult # 全局变量 #global token # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] param = eval(case['Params']) headers = dict(token=get_token()) # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print(resp.json()) message = resp.json()["code"] print(message) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_clickedit(self, case): """点击项目编辑的所有接口""" global TestResult # 全局变量 # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] headers = dict(token=get_token()) headers['Content-type'] = "application/x-www-form-urlencoded" param1 = (case['Params']) if "%s" in param1: projectId = getattr(GetData, "projectId") param1 = param1 % projectId param = param1.encode("utf-8") else: param2 = (case['Params']) param = param2.encode("utf-8") # 发起测试 # res = HttpRequests().http_request(method,url,param,headers,verify=False) My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) message = resp.json()["code"] try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_login(self, case): """登陆""" global TestResult # 全局变量 global token # 执行测试 method = case['Method'] url = case['Url'] param = eval(case['Params']) # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format(case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param,verify=False) data=resp.json() print(data) print(data.get('code')) if data.get('code')==1: return data = resp.json()['data'] print(data) if token is None: # 判断token是否为空 token = data.get("token") print(token) #return token message= resp.json()["code"] print(message) #print(type(message)) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, message) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_case(self, case): global TestResult # 全局变量 global token # 执行测试 method = case['Method'] url = case['Url'] param = eval(case['Params']) # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, verify=False) data = resp.json() print(data) print(data.get('code')) if data.get('code') == 1: return data = resp.json()['data'] print(data) if token is None: # 判断token是否为空 token = data.get("token") print(token)
def test_o5_findSetupAuditList(self, case): '''获取立项审核列表数据''' global TestResult # 全局变量 # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] param = (case['Params']) headers = dict(token=getattr(GetData, "token_chenzhihong")) headers['Content-type'] = "application/x-www-form-urlencoded" # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print(resp.json()) message = resp.json()["code"] try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_case(self, case): global TestResult # 全局变量 # global COOKIES # 执行测试 method = case['Method'] url = case['Url'] param = eval(case['Params']) # 发起测试 if case['sql'] != None: before_amount = int(DoMysql().do_mysql( eval(case['sql'])['sql'], 1)[0]) My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, cookies=getattr(GetData, 'COOKIE')) if resp.cookies: # 判断cookies是否为空 setattr(GetData, 'COOKIE', resp.cookies) try: if case['sql'] != None: after_amount = int(DoMysql().do_mysql( eval(case['sql'])['sql'], 1)[0]) print('充值后余额.{}'.format(after_amount)) recharge_amount = int(param['amount']) print('充值余额.{}'.format(recharge_amount)) ecpect_amount = before_amount + recharge_amount self.assertEqual(after_amount, ecpect_amount) if case['ExpectedResult'].find('expect_amount') > -1: case['ExpectedResult'] = case['ExpectedResult'].replace( 'expect_amount', str(ecpect_amount)) print(case['ExpectedResult']) self.assertEqual(eval(case['ExpectedResult']), resp.json()) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_case(self, case): global TestResult url = case['Url'] method = case['Method'] param = eval(case['Params']) # if case['Params'].find('loanid') != -1: # param = eval(case['Params'].replace('loanid', str(getattr(GetData, 'LOAN_ID')))) # else: # param = eval(case['Params']) My_log.info('---------正在测试{}模块里的第{}条测试用例{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) # 投标前的账户金额查询 if case['sql'] != None: before_amount = int(DoMysql().do_mysql( eval(case['sql'])['sql'], 1)[0]) print('投资前金额{}'.format(before_amount)) resp = HttpRequests().http_request(method, url, param, cookies=getattr(GetData, 'COOKIE')) if resp.cookies: setattr(GetData, 'COOKIE', resp.cookies) # 发送 try: self.assertEqual(eval(case['ExpectedResult']), resp.json()) # 投标后账户金额查询 if case['sql'] != None: after_amount = int(DoMysql().do_mysql( eval(case['sql'])['sql'], 1)[0]) print('投资后金额{}'.format(after_amount)) invest_amount = int(param['amount']) print('投资金额{}'.format(invest_amount)) ecpect_amount = before_amount - invest_amount print('投资后预期金额{}'.format(ecpect_amount)) self.assertEqual(after_amount, ecpect_amount) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试中出现错误{}'.format(e)) raise e finally: self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是{}'.format(TestResult))
def test_case(self, case): global TestResult # 全局变量 # global COOKIES # 执行测试 method = case['Method'] url = case['Url'] if case['Params'].find('loanid') != -1: # param里面发现loanid param = eval(case['Params'].replace( 'loanid', str(getattr(GetData, 'LOAN_ID')))) # 将param里loanid替换 else: param = eval(case['Params']) # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, cookies=getattr(GetData, 'COOKIE')) if case['sql'] != None: loan_id = DoMysql().do_mysql(eval( case['sql'])['sql'], 1) # 从大的case字典里取出sql的字典,并通过键值对取出sql查询语句 setattr(GetData, 'LOAN_ID', loan_id[0]) if resp.cookies: # 判断cookies是否为空 setattr(GetData, 'COOKIE', resp.cookies) try: self.assertEqual(eval(case['ExpectedResult']), resp.json()) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_case(self, case): global TestResult # 全局变量 # 执行测试 method = case['Method'] url = case['Url'] param = eval(case['Params']) # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, None) try: self.assertEqual(eval(case['ExpectedResult']), resp.json()) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_addproject(self, case): """创建项目合同价的校验""" global TestResult # 全局变量 global value # 全局变量 创建项目后获取的项目ID # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] param = (case['Params']) headers = dict(token=get_token()) headers['Content-type'] = "application/x-www-form-urlencoded" # 发起测试 My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print(resp.json()) message = resp.json()["code"] print(message) #把项目id放到datatree接口的参数里面 # projectIdvalue=resp.json()["data"]["projectId"] # value="projectId"+"="+str(projectIdvalue) # setattr(GetData,"projectId",value) # print('vaue的值是>>>>>>>>>>'+value) # self.Z=DoExcel(project_path.case_path, 'dataTree') # self.Z.write_back(2, 6, str(value)) # #把项目id放到chaozhao接口中 # self.Z = DoExcel(project_path.case_path, 'chaozhao') # self.Z.write_back(2, 6, str(value)) # self.Z.write_back(6, 6, str(value)) # self.Z.write_back(8, 6, str(value)) # self.Z.write_back(9, 6, str(value)) # self.Z.write_back(10, 6, str(value)) # #把项目id放到clickit接口中 # self.Z = DoExcel(project_path.case_path, 'clickedit') # self.Z.write_back(2, 6, str(value)) # self.Z.write_back(5, 6, str(value)) # self.Z.write_back(7, 6, str(value)) # self.Z.write_back(8, 6, str(value)) # #把项目id放入projectinfo接口中 # self.Z = DoExcel(project_path.case_path, 'projectinfo') # self.Z.write_back(4, 6, str(value)) # self.Z.write_back(5, 6, str(value)) # self.Z.write_back(6, 6, str(value)) # self.Z.write_back(8, 6, str(value)) # self.Z.write_back(9, 6, str(value)) # #把项目id放入到lixiang接口中 # self.Z = DoExcel(project_path.case_path, 'lixiang') # self.Z.write_back(2, 6, str(value)) # self.Z.write_back(3, 6, str(value)) # self.Z.write_back(5, 6, str(value)) # self.Z.write_back(6, 6, str(value)) # self.Z.write_back(8, 6, str(value)) # self.Z.write_back(9, 6, str(value)) # #把项目id放入到clickproject接口中 # self.Z = DoExcel(project_path.case_path, 'clickproject') # self.Z.write_back(2, 6, str(value)) # self.Z.write_back(4, 6, str(value)) # self.Z.write_back(5, 6, str(value)) # print(type(message)) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果
def test_o3_intprojectnumber(self, case): """获取立项号""" # 执行测试 method = case['Method'] env = ReadConfig(project_path.conf_path_username).get_data( 'runenv', 'env') url1 = ReadConfig(project_path.conf_path_username).get_data( 'environment', env) url = url1 + case['Url'] print("url的值>>>>>>>>>>>>>>>" + url) param1 = (case['Params']) print("param1>>>>>>>>>>>>>>>>>" + param1) headers = dict(token=getattr(GetData, "token_chenzhihong")) headers['Content-type'] = "application/x-www-form-urlencoded" print(headers) # 发起测试 if "%" in param1: # 使用占位符的方法,没法匹配多个%s projectId = getattr(GetData, "projectId") print("projectId>>>>>>>>>>>>" + str(projectId)) param1 = param1 % ({"projectId": projectId}) param = param1.encode("utf-8") else: param2 = (case['Params']) param = param2.encode("utf-8") My_log.info('------正在测试{}模块里的第{}条测试用例:{}'.format( case['Module'], case['CaseId'], case['Title'])) My_log.info('测试数据是{}'.format(case)) resp = HttpRequests().http_request(method, url, param, headers, verify=False) print("respone>>>>>>>>>>>>>>" + str(resp.json())) message = resp.json()["code"] # 把项目id放到datatree接口的参数里面 if case['CaseId'] == 1: projectNumbervalue = resp.json()["data"]["projectNumber"] setattr(GetData, "projectNumber", projectNumbervalue) print('projectNumber的值是>>>>>>>>>>' + projectNumbervalue) originalInvestorId = resp.json( )["data"]["companyList"][0]["originalInvestorId"] setattr(GetData, "originalInvestorId", originalInvestorId) print('originalInvestorId的值>>>>>>>>>>' + str(originalInvestorId)) try: print(type(case['ExpectedResult'])) self.assertEqual(str(case['ExpectedResult']), str(message)) TestResult = 'pass' except AssertionError as e: TestResult = 'failed' My_log.error('测试执行过程中出错,错误是:{}'.format(e)) raise e finally: # 写回结果 self.T.write_back(case['CaseId'] + 1, 9, resp.text) self.T.write_back(case['CaseId'] + 1, 10, TestResult) My_log.info('测试结果是:{}'.format(TestResult)) # http发送请求拿回的实际结果