def test01_Taskscompletere(self): #依賴其他接口 get_xls = commons.get_xls("caseforparame.xlsx", "Addrp") 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) # xls_reponses = commons.Deposit_xls_relyon("caseforparame.xlsx", "Taskscompletere", "Repairreapply", self.case_name) # xls_reponse = json.loads(xls_reponses) # set url self.url = commons.get_url_from_xml('Taskscompletere') self.url_new = self.url.split("/") self.id_change = commons.get_parameter_from_xls(xls_reponse,'id',None) self.url_last = "/"+self.url_new[1]+"/"+str(self.id_change)+"/"+self.url_new[2] configHttp.set_url(self.url_last) print("第一步:设置url "+self.url_last) # 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 = {"Content-Type": Content_Type,'Authorization':Authorization_id,'Cache-Control':no_cache} print('header%s ' % header ) configHttp.set_headers(header) print("第二步:设置header等") # set params data = { "attachmentIds":[self.attachmentIds], "costPrice":self.costPrice, "remarks": self.remarks } DATE = json.dumps(data) print('DATE%s' % DATE) configHttp.set_data(DATE) print("第三步:设置发送请求的参数") self.logger.info("********creater********") try: self.return_json = configHttp.post() 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
def test01_Maintenancedetail(self): # 依賴其他接口 get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addrepair") try: xls_01 = get_xls_Addrepair[0] xls_02 = get_xls_Addrepair[1] except: print("超出列表值") xls_reponses_Addrepairs = get_xls_Addrepair[0][-1] xls_reponses_Addrepair = json.loads(xls_reponses_Addrepairs) # set url self._testMethodDoc = self.case_name self.url = commons.get_url_from_xml('Maintenancedetail') self.id_change = commons.get_parameter_from_xls(xls_reponses_Addrepair, 'id', None) self.url_last = self.url + "/" + str(self.id_change) configHttp.set_url(self.url_last) print("第一步:设置url " + self.url_last) #set headers Content_Type = localReadConfig.get_headers('Content-Type') no_cache = localReadConfig.get_headers('Cache-Control') header = {"Content-Type": Content_Type,'Authorization':Authorization_id,'Cache-Control':no_cache} print('header%s ' % header ) configHttp.set_headers(header) print("第二步:设置header等") #set params # data = { # "attachmentId": self.attachmentId, # "cnName":self.cnName, # "employeeId":self.employeeId, # "enName":self.enName, # "isReleased":self.isReleased, # "tel":self.tel # } # # DATE = json.dumps(data) # print('DATE%s' % DATE) # configHttp.set_data(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
def test01_Repairurge(self): #依賴其他接口 get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addrepair") try: xls_01 = get_xls_Addrepair[0] xls_02 = get_xls_Addrepair[1] except: print("超出列表值") xls_reponses_Addrepairs = get_xls_Addrepair[0][-1] xls_reponses_Addrepair = json.loads(xls_reponses_Addrepairs) # set url self.url = commons.get_url_from_xml('Repairurge') self.url_new = self.url.split("/") self.id_change = commons.get_parameter_from_xls(xls_reponses_Addrepair,'id',None) self.url_last = "/"+self.url_new[1]+"/"+str(self.id_change)+"/"+self.url_new[2] configHttp.set_url(self.url_last) print("第一步:设置url "+self.url_last) # 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 = {"Content-Type": Content_Type,'Authorization':Authorization_id,'Cache-Control':no_cache} print('header%s ' % header ) configHttp.set_headers(header) print("第二步:设置header等") # set params # data = { # "isRepair ":self.isRepair # } # DATE = json.dumps(data) # print('DATE%s' % DATE) # # configHttp.set_params(DATE) print("第三步:设置发送请求的参数") self.logger.info("********creater********") try: self.return_json = configHttp.post() 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
def test01_Dispatchingre(self): #依賴其他接口參數 get_xls = commons.get_xls("caseforparame.xlsx", "Addrp") 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) # xls_reponses = commons.Deposit_xls_relyon("caseforparame.xlsx", "Dispp", "Repairreapply", self.case_name) # xls_reponse = json.loads(xls_reponses) # set url print('case ###############################################%s' % self.case_name) self._testMethodDoc = self.case_name self.url = commons.get_url_from_xml('Dispp') self.id_change = commons.get_parameter_from_xls( xls_reponse, "id", None) self.url_new = self.url + "/" + str(self.id_change) 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 = { "Content-Type": Content_Type, 'Authorization': Authorization_id, 'Cache-Control': no_cache } print('header%s ' % header) configHttp.set_headers(header) print("第二步:设置header等") # set params data = { "day": self.day, "operation": self.operation, "receiverCnName": self.receiverCnName, "receiverEnName": self.receiverEnName, "receiverId": self.receiverId, "receiverIsoutsider": self.receiverIsoutsider, "remarks": self.remarks } DATE = json.dumps(data) print('DATE%s' % DATE) configHttp.set_data(DATE) print("第三步:设置发送请求的参数") self.logger.info("********creater********") # test interface try: self.return_json = configHttp.post() 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 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", "Itemsdetails") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Itemsdetails(unittest.TestCase): def setParameters(self, case_name, id, result, response): self.case_name = str(case_name) self.id_change = id self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_Itemsdetails(self): # 依賴其他接口 get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addproject")
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", "Groupdetail") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Groupdetail(unittest.TestCase): def setParameters(self, case_name, id, result, response): self.case_name = str(case_name) self.id_change = id self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_Groupdetail(self): # 依賴其他接口 get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "AddGroups")
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", "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):
def test01_Repairreapply(self): #依赖其他接口数据 get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addrepair") try: xls_02 = get_xls_Addrepair[4] except: print("超出列表值") xls_reponses_Addrepairs = get_xls_Addrepair[4][-1] xls_reponses_Addrepair = json.loads(xls_reponses_Addrepairs) # set url # pa = json.loads(self.relyon_response) self.url = commons.get_url_from_xml('Repairreapply') self.url_new = self.url.split("/") self.id_change = commons.get_parameter_from_xls( xls_reponses_Addrepair, 'id', None) self.url_last = "/" + self.url_new[1] + "/" + str( self.id_change) + "/" + self.url_new[2] configHttp.set_url(self.url_last) print("第一步:设置url " + self.url_last) # 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 = { "Content-Type": Content_Type, 'Authorization': Authorization_id, 'Cache-Control': no_cache } print('header%s ' % header) configHttp.set_headers(header) print("第二步:设置header等") #set params data = { "addr": self.addr, "attachmentIds": [self.attachmentIds], "id": self.id_change, "itemCnName": self.itemCnName, "itemEnName": self.itemEnName, "itemId": self.itemId, "landCnName": self.landCnName, "landEnName": self.landEnName, "landId": self.landId, "remark": self.remark, "roomCnName": self.roomCnName, "roomEnName": self.roomEnName, "roomId": self.roomId, "roomTypeKey": self.roomTypeKey, "tel": self.tel } DATE = json.dumps(data) print('DATE%s' % DATE) configHttp.set_data(DATE) print("第三步:设置发送请求的参数") self.logger.info("********creater********") try: self.return_json = configHttp.post() 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
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 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", "Itemsupdate") print('create_house_xls %s ' % create_house_xls) localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Itemsupdate(unittest.TestCase): def setParameters(self,case_name, id,cnName, enName, isApplyToStudent, isApplyToTeacher, isNeedAuditStudent, isNeedAuditTeacher, isReleased, roomTypeCnName,roomTypeEnName,roomTypeId,roomTypeKey,sn,result,response): self.case_name = str(case_name) self.id_change = int(id) self.cnName = str(cnName) self.enName = str(enName) self.isApplyToStudent = int(isApplyToStudent) self.isApplyToTeacher = int(isApplyToTeacher) self.isNeedAuditStudent = int(isNeedAuditStudent) self.isNeedAuditTeacher = int(isNeedAuditTeacher) self.isReleased = int(isReleased) self.roomTypeCnName = str(roomTypeCnName)
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", "Maintenancedetail") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Maintenancedetail(unittest.TestCase): def setParameters(self,case_name,id,result,response): self.case_name = str(case_name) self.id_change = id self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_Maintenancedetail(self): # 依賴其他接口 get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addrepair")
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", "Addousider") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Addousider(unittest.TestCase): def setParameters(self, case_name, attachmentId, cnName, employeeId, enName, isReleased, tel, result, response): self.case_name = str(case_name) self.attachmentId = int(attachmentId) self.cnName = cnName self.employeeId = int(employeeId) self.enName = enName self.isReleased = int(isReleased) self.tel = str(tel) self.result = result 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", "Repairslist") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Repairslist(unittest.TestCase): def setParameters(self, case_name, keywords, maxPageItems, offsetStart, result, response): self.case_name = str(case_name) self.keywords = keywords self.maxPageItems = maxPageItems self.offsetStart = offsetStart 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", "Approvalhistorys") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization() list_info = [] @paramunittest.parametrized(*create_house_xls) class Approvalhistorys(unittest.TestCase): def setParameters(self, case_name, id, isRepair, result, response): self.case_name = str(case_name) self.id_change = int(id) self.isRepair = str(isRepair) self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_Approvalhistorys(self):
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", "GroupsgetStudent") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class GroupsgetStudent(unittest.TestCase): def setParameters(self, case_name, result, response): self.case_name = str(case_name) self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_GroupsgetStudent(self): # set url self._testMethodDoc = 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", "Groupslist") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Groupslist(unittest.TestCase): def setParameters(self, case_name, keywords, maxPageItems, offsetStart, type_change, result, response): self.case_name = str(case_name) self.keywords = keywords self.maxPageItems = maxPageItems self.offsetStart = offsetStart self.type_change = type_change 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", "Upload") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Upload(unittest.TestCase): def setParameters(self,case_name, fileData,relateType,result,response): self.case_name = str(case_name) self.fileData = fileData self.relateType = relateType self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_Upload(self): # set url self._testMethodDoc = self.case_name
def test01_Itemsupdate(self): get_xls_Addrepair = commons.get_xls("caseforparame.xlsx", "Addproject") try: xls_01 = get_xls_Addrepair[0] xls_02 = get_xls_Addrepair[1] except: print("超出列表值") xls_reponses_Addrepairs = get_xls_Addrepair[0][-1] xls_reponses_Addrepair = json.loads(xls_reponses_Addrepairs) # set url self._testMethodDoc = self.case_name self.url = commons.get_url_from_xml('Itemsupdate') self.id_change = commons.get_parameter_from_xls(xls_reponses_Addrepair, 'id', None) self.url_new = self.url + "/" + str(self.id_change) configHttp.set_url(self.url_new) print("第一步:设置url "+self.url_new) #set headers Content_Type = localReadConfig.get_headers('Content-Type') no_cache = localReadConfig.get_headers('Cache-Control') header = {"Content-Type": Content_Type,'Authorization':Authorization_id,'Cache-Control':no_cache} print('header%s ' % header ) configHttp.set_headers(header) print("第二步:设置header等") # set params data = { "cnName":self.cnName, "enName": self.enName , "isApplyToStudent":self.isApplyToStudent , "isApplyToTeacher": self.isApplyToTeacher, "isNeedAuditStudent": self.isNeedAuditStudent, "isNeedAuditTeacher": self.isNeedAuditTeacher, "isReleased": self.isReleased, "roomTypeList": [ { "roomTypeCnName": self.roomTypeCnName, "roomTypeEnName": self.roomTypeEnName, "roomTypeId": self.roomTypeId, "roomTypeKey": self.roomTypeKey } ], "sn": self.sn } DATE = json.dumps(data) print('DATE%s' % DATE) configHttp.set_data(DATE) print("第三步:设置发送请求的参数") self.logger.info("********creater********") # test interface try: self.return_json = configHttp.post() 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 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", "listRepairUsers") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization() list_info = [] @paramunittest.parametrized(*create_house_xls) class ListRepairUsers(unittest.TestCase): def setParameters(self,case_name,keywords,maxPageItems,offsetStart,repairId,result,response): self.case_name = str(case_name) self.keywords = str(keywords) self.maxPageItems = maxPageItems self.offsetStart = offsetStart self.repairId = repairId self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备")
# -*- coding: UTF-8 -*- #新增項目接口 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, threading import os import sys Addrepair_xls = commons.get_xls("caseforparame.xlsx", "Groupsedit") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization() list_info = [] filename = os.path.basename(sys.argv[0]).split(".")[0] @paramunittest.parametrized(*Addrepair_xls) class Groupsedit(unittest.TestCase): def setParameters(self, case_name, id, areaId, cnName, enName, landCnName, landEnName, landId, itemId, isOutsider, key, thumb, userCnName, userEnName, userId, isReleased, departmentCnName, departmentEnName, departmentId, sdepartmentCnName, sdepartmentEnName, sdepartmentId, type, result, response):
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", "Repairreapply") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization() list_info = [] @paramunittest.parametrized(*create_house_xls) class Repairreapply(unittest.TestCase): def setParameters(self, case_name, id_changes, addr, attachmentIds, id, itemCnName, itemEnName, itemId, landCnName, landEnName, landId, remark, roomCnName, roomEnName, roomId, roomTypeKey, tel, result, response, relyon_response): self.case_name = str(case_name) self.id_changes = id_changes self.addr = str(addr) self.attachmentIds = int(attachmentIds) self.id_change = int(id) self.itemCnName = str(itemCnName) self.itemEnName = str(itemEnName)
def test01_Groupsedit(self): #依賴其他接口參數 Addproject_xls = commons.get_xls("caseforparame.xlsx", "AddGroups") xls_01 = Addproject_xls[0] xls_02 = Addproject_xls[1] xls_reponses = Addproject_xls[0][-1] xls_reponse = json.loads(xls_reponses) # set url print('case ###############################################%s' % self.case_name) self._testMethodDoc = self.case_name self.url = commons.get_url_from_xml('Groupsedit') self.id_change = commons.get_parameter_from_xls( xls_reponse, "id", None) self.url_new = self.url + str(self.id_change) configHttp.set_url(self.url) print("第一步:设置url " + self.url) # 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 = { "Content-Type": Content_Type, 'Authorization': Authorization_id, 'Cache-Control': no_cache } print('header%s ' % header) configHttp.set_headers(header) print("第二步:设置header等") #從上一個接口獲取項目id,名稱 # self.itemCnName = commons.get_parameter_from_xls(xls_reponse,"cnName",None) # self.itemEnName = commons.get_parameter_from_xls(xls_reponse,"enName",None) # self.itemId = commons.get_parameter_from_xls(xls_reponse,"id",None) # set params data = { "areaId": self.areaId, "cnName": self.cnName, "enName": self.enName, "groupHasBuildingOptionList": [{ "landCnName": self.landCnName, "landEnName": self.landEnName, "landId": self.landId }], "groupHasItemOptionList": [{ "itemId": self.itemId }], "groupHasUserOptionList": [{ "isOutsider": self.isOutsider, "key": self.key, "thumb": self.thumb, "userCnName": self.userCnName, "userEnName": self.userEnName, "userId": self.userId }], "isReleased": self.isReleased, "studentGroupHasDepartmentList": [{ "departmentCnName": "", "departmentEnName": "", "departmentId": "" }], "teacherGroupHasDepartmentList": [{ "departmentCnName": "", "departmentEnName": "", "departmentId": "" }], "type": self.types } DATE = json.dumps(data) print('DATE%s' % DATE) configHttp.set_data(DATE) print("第三步:设置发送请求的参数") self.logger.info("********creater********") # test interface try: self.return_json = configHttp.post() 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 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", "Outsiders") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class RoomList(unittest.TestCase): def setParameters(self,case_name, keywords,maxPageItems,offsetStart,result,response): self.case_name = str(case_name) self.keywords = keywords self.maxPageItems = maxPageItems self.offsetStart = offsetStart self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_Outsiders(self): # set url
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", "Repairsmanagement") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class Repairsmanagement(unittest.TestCase): def setParameters(self, case_name, endDate, keywords, keywordsType, lang, maxPageItems, offsetStart, startDate, result, response): self.case_name = str(case_name) self.endDate = endDate self.keywords = keywords self.keywordsType = keywordsType self.lang = lang self.maxPageItems = maxPageItems self.offsetStart = offsetStart self.startDate = startDate self.result = result def setUp(self):
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", "DispatchingTags") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class DispatchingTags(unittest.TestCase): def setParameters(self,case_name,result,response): self.case_name = str(case_name) self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_DispatchingTags(self): # set url self._testMethodDoc = self.case_name self.url = commons.get_url_from_xml('DispatchingTags')
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", "Getroom") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() info = {} Authorization_id = commons.get_Authorization() @paramunittest.parametrized(*create_house_xls) class RoomList(unittest.TestCase): def setParameters(self, case_name, itemId, result, response): self.case_name = str(case_name) self.itemId = itemId self.result = result def setUp(self): self.log = MyLog.get_log() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备") def test01_RoomList(self): # set url self._testMethodDoc = self.case_name
# -*- coding: UTF-8 -*- #新增項目接口 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, threading import os import sys Addrepair_xls = commons.get_xls("caseforparame.xlsx", "AddGroups") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization() list_info = [] filename = os.path.basename(sys.argv[0]).split(".")[0] @paramunittest.parametrized(*Addrepair_xls) class AddGroups(unittest.TestCase): def setParameters(self, case_name, areaId, cnName, enName, landCnName, landEnName, landId, itemId, isOutsider, key, thumb, userCnName, userEnName, userId, isReleased, departmentCnName, departmentEnName, departmentId, sdepartmentCnName, sdepartmentEnName, sdepartmentId, type, result, response):
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", "Repaircomplete") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization() list_info = [] @paramunittest.parametrized(*create_house_xls) class Repaircomplete(unittest.TestCase): def setParameters(self, case_name, id, serviceEvaluation, serviceScore, result, response): self.case_name = str(case_name) self.id_change = int(id) self.serviceEvaluation = serviceEvaluation self.serviceScore = serviceScore 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", "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", "PostmaintenanceTasks") localReadConfig = readConfig.ReadConfig() configHttp = ConfigHttp.ConfigHttp() Authorization_id = commons.get_Authorization("test37","123456","Authorizationid_repair") list_info = [] @paramunittest.parametrized(*create_house_xls) class PostmaintenanceTasks(unittest.TestCase): def setParameters(self,case_name,operation,remarks,id,result,response,relyon_response): self.case_name = str(case_name) self.operation = str(operation) 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() self.logger = self.log.get_logger() # print(self.case_name+"测试开始前准备")