import unittest import paramunittest import readConfig as readConfig from common.log import Log from common import commons from common import configHttp as ConfigHttp from common.log import MyLog import json create_house_xls = commons.get_xls("caseforparame.xlsx", "Getdispatching") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Getdispatching(unittest.TestCase): def setParameters(self, case_name, keywords, maxPageItems, offsetStart, status, result, response): self.case_name = str(case_name) self.keywords = str(keywords) self.maxPageItems = maxPageItems self.offsetStart = offsetStart self.status = status self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备")
import unittest import paramunittest import readConfig as readConfig from common.log import Log from common import commons from common import configHttp as ConfigHttp from common.log import MyLog import json create_house_xls = commons.get_xls("caseforparame.xlsx", "Dispatchingre") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization("test87", "123456", "Authorizationid_dispatching") list_info = [] @paramunittest.parametrized(*create_house_xls) class Dispatchingre(unittest.TestCase): def setParameters(self, case_name, id, day, operation, receiverCnName, receiverEnName, receiverId, receiverIsoutsider, remarks, result, response, relyon_response): self.case_name = str(case_name) self.id_change = int(id) self.day = int(day) self.operation = str(operation) self.receiverCnName = str(receiverCnName) self.receiverEnName = str(receiverEnName) self.receiverId = int(receiverId) self.receiverIsoutsider = int(receiverIsoutsider)
def test01_listRepairUsers(self): #依賴其他接口參數 get_xls = commons.get_xls("caseforparame.xlsx", "Addrepair") try: xls_01 = get_xls[0] xls_02 = get_xls[1] except: print("超出列表值") xls_reponses = get_xls[0][-1] xls_reponse = json.loads(xls_reponses) localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() # set url self.repairId = commons.get_parameter_from_xls(xls_reponse, "id", None) self._testMethodDoc = self.case_name self.url = commons.get_url_from_xml('listRepairUsers') #+"keywords="+self.keywords+ "&"+"maxPageItems="+self.maxPageItems+"&" self.url_new = self.url+"?"+"repairId="+str(self.repairId) configHttp.set_url(self.url_new) print("第一步:设置url "+self.url_new) # get visitor token # if self.token == '0': # token = localReadConfig.get_headers("token_v") # elif self.token == '1': # token = None #set headers Content_Type = localReadConfig.get_headers('Content-Type') no_cache = localReadConfig.get_headers('Cache-Control') header = {'Authorization':Authorization_id,'Cache-Control':no_cache} print('header%s ' % header ) configHttp.set_headers(header) print("第二步:设置header等") # set params # data = { # "keywords":self.keywords, # "maxPageItems": self.maxPageItems, # "offsetStart": self.offsetStart, # "repairId ":self.repairId # } # DATE = json.dumps(data) # print('DATE%s' % DATE) # configHttp.set_params(DATE) print("第三步:设置发送请求的参数") self.logger.info("********creater********") # test interface try: self.return_json = configHttp.get() except Exception as e: print('e %s' % e) method = str(self.return_json.request)[int(str(self.return_json.request).find('['))+1:int(str(self.return_json.request).find(']'))] print("第四步:发送请求\n\t\t请求方法:"+method) print("第五步:检查结果") self.checkResult() return self.return_json
import paramunittest import readConfig as readConfig from common.log import Log from common import commons from common import configHttp as ConfigHttp from common.log import MyLog import json create_house_xls = commons.get_xls("caseforparame.xlsx", "Taskscompletere") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() # Authorization_id = commons.get_Authorization("test37","123456") Authorization_id = commons.get_Authorization("test87","123456","Authorizationid_repair") list_info = [] @paramunittest.parametrized(*create_house_xls) class Taskscompletere(unittest.TestCase): def setParameters(self,case_name,attachmentIds,costPrice,remarks,id,result,response,relyon_response): self.case_name = str(case_name) self.attachmentIds = int(attachmentIds) self.costPrice = int(costPrice) self.remarks = str(remarks) self.id_change = int(id) self.result = result self.relyon_response = relyon_response def setUp(self): self.log = MyLog.get_log()
import unittest import paramunittest import readConfig as readConfig from common.log import Log from common import commons from common import configHttp as ConfigHttp from common.log import MyLog import json create_house_xls = commons.get_xls("caseforparame.xlsx", "Approvalre") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization("test87", "123456", "Authorizationid_approvals") @paramunittest.parametrized(*create_house_xls) class Approvalre(unittest.TestCase): def setParameters(self, case_name, id, operation, remarks, result, response, relyon_response): self.case_name = str(case_name) self.id_change = int(id) self.operation = str(operation) self.remarks = str(remarks) self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger()