def loanAble(self,jwt,aid): self.url = "/gw/borrow-api/v3/companies/%s/mca-loanable"%aid self.headers = {'Authorization': jwt} self.loanReq = RequestHelper("demo","borrowapi") self.loanReq.basicRequests('get',self.url,params=self.params,headers=self.headers) print self.loanReq.response
def __init__(self, env="DEMO", testData='../TestCase/TestCaseSuit.xlsx'): self.reqOne = RequestHelper(env=env, server="borrowapi") # self.productCode = "BU-MCA-DSDAITF-000000-02" # self.productCode = "BU-MCA-SCDAIGF-000000-02" # C版本 self.productCode = "BU-MCA-SCDAITR-019709-01" self.headers = { "Content-Type": "application/json", "X-Role": "BORROWER" } self.AppAmount = 210000 if not os.path.exists(testData): LogFileHelper.logging.info("测试数据不存在") sys.exit() table = xlrd.open_workbook(testData) tableSheet = table.sheet_by_index(2) self.applicationData = eval( tableSheet.cell(1, 1).value.replace('\n', '').replace('\r', '')) self.configsData = eval( tableSheet.cell(2, 1).value.replace('\n', '').replace('\r', '')) self.updataFilesData = None self.getMaterialsData = eval( tableSheet.cell(4, 1).value.replace('\n', '').replace('\r', '')) self.putMaterialsData = eval( tableSheet.cell(5, 1).value.replace('\n', '').replace('\r', ''))
class AutoInvest(): def __init__(self, env="DEMO"): self.req = RequestHelper(env=env, server="fincore") def autoInvest(self, loanId): self.url = "/exposeService/service/autoInvest/%s" % loanId self.req.basicRequests("post", self.url) print self.req.response
def getLegalPersonContracts(self, jwt, aid): self.headers = {"Authorization": jwt} self.url = "/gw/borrow-api/v3/borrowers/%s/phase-contracts" % aid self.reqOne = RequestHelper("demo", "borrowapi") self.reqOne.basicRequests("get", self.url, params=self.params, headers=self.headers) return self.reqOne.response
class Login(): # def __init__(self,env="DEMO"): # LogFileHelper.logging.info(u"=====================================start loginlite") # self.suburl = "/auth-server/api/jwt/pwd/login" # self.headers = {"X-Role":"BORROWER","Content-Type": "application/x-www-form-urlencoded"} # self.requestOne = RequestHelper(env=env,server="auth") # self.params = {"identity":"15121000080","password":"******"} # self.requestOne.basicRequests(method="post", suburl=self.suburl, headers=self.headers,data=self.params) def __init__(self,env="DEMO",dataFile=r"E:\pythonWorkspace\mcah5\TestCase\TestCaseSuit.xlsx"): LogFileHelper.logging.info(u"=====================================start loginlite") print dataFile,env self.requestOne = RequestHelper(env=env,server='auth') self.url = "/auth-server/api/jwt/pwd/login" if not os.path.exists(dataFile): LogFileHelper.logging.error('测试用例文件不存在!!!') sys.exit() testCase = xlrd.open_workbook(dataFile) table = testCase.sheet_by_index(0) for i in range(1,table.nrows): self.num=int(table.cell(i,0).value) self.api=table.cell(i,1).value.replace('\n', '').replace('\r', '') self.host= table.cell(i,2).value.replace('\n', '').replace('\r', '') self.url = table.cell(i,3).value.replace('\n','').replace('\r','') self.method = table.cell(i, 4).value.replace('\n', '').replace('\r', '') self.params = eval(table.cell(i,5).value.replace('\n', '').replace('\r', '')) self.bodyJson = table.cell(i,6).value.replace('\n', '').replace('\r', '') self.headers = eval(table.cell(i, 7).value.replace('\n', '').replace('\r', '')) self.filePath = table.cell(i, 8).value.replace('\n', '').replace('\r', '') self.correlation = table.cell(i,9).value.replace('\n','').replace('\r','') self.requestOne.basicRequests(self.method,self.url,headers=self.headers,data=self.params) # # def getTestcase(self,dataFile):BU-MCA-SCDAIGR-019709-01 # if not os.path.exists(dataFile): # LogFileHelper.logging.error('测试用例文件不存在!!!') # sys.exit() # testCase = xlrd.open_workbook(dataFile) # table = testCase.sheet_by_index(0) # for i in range(1,table.nrows): # self.num=table.cell(i,0).value # self.api=table.cell(i,1).value # self.params= table.cell(i,2).value # self.headers = table.cell(i, 3).value # self.expectResponse=table.cell(i, 4).value # print self.num,self.api,self.params,self.headers,self.expectResponse def login(self): if self.requestOne.status_code == 200: print self.requestOne.response['content']['authenticationJwt'] return self.requestOne.response['content']['authenticationJwt'] else: print "fail" return None
class AutoInvest(): def __init__(self, env='demo'): LogFileHelper.logging.info("Start invotest================") self.loanId = 790959 self.req = RequestHelper(env=env, server="fincore") #自动募集 def test_autoInvest(self, loanId): self.url = "/exposeService/service/autoInvest/%s" % loanId self.req.basicRequests("post", self.url) return self.req.response #自动放款 def test_autoLoan(self, loanId): self.url = "/exposeService/service/hourly/%s" % loanId self.req.basicRequests("post", self.url) print self.req.response return self.req.response #查看还款计划 def test_paymentPlan(self, loanId): self.url = "/exposeService/service/payment_plan/submitted/%s" % loanId self.req.basicRequests("get", self.url) print self.req.response billList = self.req.response['content']['bills'] return billList #生成每期账单 def test_paymentDate(self, loanId, dueDate): self.url = "/exposeService/service/NewPaymentScheduler/loanId/%s/paymentDate/%s" % ( loanId, dueDate) self.req.basicRequests('post', self.url) print json.dumps(self.req.response, ) #还款 def test_repayment(self, loanId, dueDate): # for value in paymentDate: # dueDate2 = value.get("dueDate","") self.url = "/exposeService/service/NewPaymentProcessor/loanId/%s/paymentDate/%s" % ( loanId, dueDate) self.req.basicRequests('post', self.url) print self.req.response #循环还清每笔账单 def test_allRepayment(self, loanId, planDates): self.count = 0 for planDate in planDates: dueDate = planDate.get("dueDate", "") # print dueDate, # self.count+=1 # print self.count self.test_paymentDate(loanId, dueDate) self.test_repayment(loanId, dueDate)
class GetLegalPersonAid(): def __init__(self,env = "DEMO"): self.subUrl = "/gw/borrow-api/v3/borrowers/self" self.reqOne = RequestHelper(env=env,server="borrowapi") def selfInformation(self,jwt): self.headers = {'Authorization':jwt} time.sleep(5) self.reqOne.basicRequests("get", self.subUrl,headers = self.headers) print self.reqOne.response['id'] return self.reqOne.response['id']
class McaLoanable(): def __init__(self,env="demo"): self.params = {"loanProductCode": "MCA_GREENLANE_ONLINE"} def loanAble(self,jwt,aid): self.url = "/gw/borrow-api/v3/companies/%s/mca-loanable"%aid self.headers = {'Authorization': jwt} self.loanReq = RequestHelper("demo","borrowapi") self.loanReq.basicRequests('get',self.url,params=self.params,headers=self.headers) print self.loanReq.response
class GetLegalPersonContracts(): def __init__(self, env=None): self.params = {"phase": "REALNAME", "owner": "COMMON_RONGLI"} def getLegalPersonContracts(self, jwt, aid): self.headers = {"Authorization": jwt} self.url = "/gw/borrow-api/v3/borrowers/%s/phase-contracts" % aid self.reqOne = RequestHelper("demo", "borrowapi") self.reqOne.basicRequests("get", self.url, params=self.params, headers=self.headers) return self.reqOne.response
class PersonRealName(): def __init__(self, env="demo"): self.requestOne = RequestHelper("demo", "borrowapi") self.ssn = 420322198706285700 self.name = "单小丽" def personRealName(self, jwt, aid): self.headers = {'Authorization': jwt} self.Url = "/gw/borrow-api/v3/borrowers/%s/real-name?productCode=MCA_GREENLANE_ONLINE&ssn=%s&permanentAddr=undefined&name=u'%s'" % ( aid, self.ssn, self.name) self.requestOne.basicRequests(method="put", suburl=self.Url, headers=self.headers) self.response = self.requestOne.response return self.response
class RelationCompany(): def __init__(self, env=None): self.relationReq = RequestHelper("demo", "borrowapi") def relationCompany(self, jwt, aid): self.url = "/gw/borrow-api/v3/borrowers/%s/relative-users?relationType=IS_LEGAL_REP" % aid self.headers = {'Authorization': jwt} # self.params = {"relationType":"IS_LEGAL_REP"} self.relationReq.basicRequests('get', self.url, headers=self.headers) print json.dumps(self.relationReq.response, ensure_ascii=False) print(len(self.relationReq.response)) # for jb in self.relationReq.response: # return jb print self.relationReq.response[0]["id"] return self.relationReq.response[0]["id"]
class UpLoadDocuments(): def __init__(self): self.Req = RequestHelper("demo", "borrowapi") self.headers = {} def upLoadDocuments(self,jwt,companyId,loanAppId): self.headers["Authorization"]=jwt self.updataFiles = ["SV_APP_ORIGINAL_BUSINESS_LICENSE","SV_LEGAL_REPRESENTATIVE_IDENTITY_CARD"] for updataFile in self.updataFiles: print type(updataFile) self.param = {"docType": updataFile} self.files = {'uploadedFiles': ("1.jpg", open("C:\\1.jpg", 'rb'), "images/jpg")} self.url = "/gw/zuul/borrow-api/v3/borrowers/%s/applications/%s/documents/" %(companyId, loanAppId) self.Req.basicRequests("post",self.url,files=self.files,headers=self.headers,data=self.param) print self.Req.response
def __init__(self,env="DEMO",dataFile=r"E:\pythonWorkspace\mcah5\TestCase\TestCaseSuit.xlsx"): LogFileHelper.logging.info(u"=====================================start loginlite") print dataFile,env self.requestOne = RequestHelper(env=env,server='auth') self.url = "/auth-server/api/jwt/pwd/login" if not os.path.exists(dataFile): LogFileHelper.logging.error('测试用例文件不存在!!!') sys.exit() testCase = xlrd.open_workbook(dataFile) table = testCase.sheet_by_index(0) for i in range(1,table.nrows): self.num=int(table.cell(i,0).value) self.api=table.cell(i,1).value.replace('\n', '').replace('\r', '') self.host= table.cell(i,2).value.replace('\n', '').replace('\r', '') self.url = table.cell(i,3).value.replace('\n','').replace('\r','') self.method = table.cell(i, 4).value.replace('\n', '').replace('\r', '') self.params = eval(table.cell(i,5).value.replace('\n', '').replace('\r', '')) self.bodyJson = table.cell(i,6).value.replace('\n', '').replace('\r', '') self.headers = eval(table.cell(i, 7).value.replace('\n', '').replace('\r', '')) self.filePath = table.cell(i, 8).value.replace('\n', '').replace('\r', '') self.correlation = table.cell(i,9).value.replace('\n','').replace('\r','') self.requestOne.basicRequests(self.method,self.url,headers=self.headers,data=self.params)
def __init__(self, env='demo'): LogFileHelper.logging.info("Start invotest================") self.loanId = 790959 self.req = RequestHelper(env=env, server="fincore")
def __init__(self,env = "DEMO"): self.subUrl = "/gw/borrow-api/v3/borrowers/self" self.reqOne = RequestHelper(env=env,server="borrowapi")
def __init__(self, env=None): self.relationReq = RequestHelper("demo", "borrowapi")
def __init__(self, env="demo"): self.requestOne = RequestHelper("demo", "borrowapi") self.ssn = 420322198706285700 self.name = "单小丽"
def __init__(self, env="DEMO"): self.req = RequestHelper(env=env, server="fincore")
def __init__(self): self.Req = RequestHelper("demo", "borrowapi") self.headers = {}
class Applications(): def __init__(self, env="DEMO", testData='../TestCase/TestCaseSuit.xlsx'): self.reqOne = RequestHelper(env=env, server="borrowapi") # self.productCode = "BU-MCA-DSDAITF-000000-02" # self.productCode = "BU-MCA-SCDAIGF-000000-02" # C版本 self.productCode = "BU-MCA-SCDAITR-019709-01" self.headers = { "Content-Type": "application/json", "X-Role": "BORROWER" } self.AppAmount = 210000 if not os.path.exists(testData): LogFileHelper.logging.info("测试数据不存在") sys.exit() table = xlrd.open_workbook(testData) tableSheet = table.sheet_by_index(2) self.applicationData = eval( tableSheet.cell(1, 1).value.replace('\n', '').replace('\r', '')) self.configsData = eval( tableSheet.cell(2, 1).value.replace('\n', '').replace('\r', '')) self.updataFilesData = None self.getMaterialsData = eval( tableSheet.cell(4, 1).value.replace('\n', '').replace('\r', '')) self.putMaterialsData = eval( tableSheet.cell(5, 1).value.replace('\n', '').replace('\r', '')) def application(self, jwt, companyId): self.url = "/gw/borrow-api/v3/borrowers/%s/applications" % companyId self.data = self.applicationData print self.data, type(self.data) self.headers['Authorization'] = jwt self.reqOne.basicRequests('post', self.url, headers=self.headers, json=self.data) print self.reqOne.response return self.reqOne.response["loanAppId"] def configs(self, jwt, aid, loanAppId, companyId): print companyId print "-----------------------------------" self.url = "/gw/borrow-api/v3/borrowers/%s/applications/%s/configs" % ( companyId, loanAppId) self.headers['Authorization'] = jwt self.data = self.configsData self.reqOne.basicRequests('put', self.url, headers=self.headers, json=self.data) print self.reqOne.response return self.reqOne.response def upLoadDocuments(self, jwt, companyId, loanAppId): self.headers = {"Authorization": jwt} self.updataFiles = [ "SV_APP_ORIGINAL_BUSINESS_LICENSE", "SV_LEGAL_REPRESENTATIVE_IDENTITY_CARD", "SV_LEGAL_REPRESENTATIVE_IDENTITY_CARD" ] for updataFile in self.updataFiles: self.param = {"docType": updataFile} self.files = { 'uploadedFiles': ("1.jpg", open("C:\\1.jpg", 'rb'), "images/jpg") } self.url = "/gw/zuul/borrow-api/v3/borrowers/%s/applications/%s/documents/" % ( companyId, loanAppId) self.reqOne.basicRequests("post", self.url, data=self.param, files=self.files, headers=self.headers) return self.reqOne.response def getMaterials(self, jwt, companyId, appid): url2 = "/gw/borrow-api/v3/borrowers/%s/applications/%s/materials" % ( companyId, appid) headers2 = {'Authorization': jwt} params2 = self.getMaterialsData self.reqOne.basicRequests("get", url2, headers=headers2, params=params2) print self.reqOne.response return self.reqOne.response def PutMaterials(self, jwt, companyId, appid, initDataOne): self.url3 = "/gw/borrow-api/v3/borrowers/%s/applications/%s/materials?configCode=mcah5" % ( companyId, appid) self.headers['Authorization'] = jwt json33 = self.putMaterialsData print type(initDataOne["data"]) for key, value in initDataOne["data"].items(): if isinstance(value, dict): for k, v in value.iteritems(): if v: json33[key][k] = v elif isinstance(value, list): for index, a in enumerate(value): for k, v in a.iteritems(): if v: json33[key][index][k] = v # pprint.pprint(json33) print json33 self.reqOne.basicRequests("put", self.url3, json=json33, headers=self.headers) print self.reqOne.response