def _createFundInfoQueryResponse(self, requestDict, expectationDict): totalNum=expectationDict.get("totalNum", 19) beginPos=requestDict["beginPos"] pageNum=requestDict["pageNum"] print "Input param: ", str(requestDict) if beginPos >= totalNum: endPos=beginPos itemCount=0 currentPageIndex=0 print "beginPos is out of total number, return null item" else: endPos=beginPos + pageNum if endPos > (totalNum - 1): endPos = totalNum itemCount=endPos - beginPos print "beginPos=", str(beginPos), ", endPos=", endPos, ", itemCount=", itemCount instId=requestDict.get('instId', 'CGB(CGBCC)') certId=requestDict.get('certId', '0001') errorCode=expectationDict.get('errorCode', '0000') errorMessage=expectationDict.get('errorMessage', '查询成功') root=self.__createElement('SoEv', parentNode=self.doc) message=self.__createElement("Message", parentNode=root, attrDict={"id":util.date2Str()}) responseBody=self.__createElement("FIQRes", parentNode=message,attrDict={"id":"FIQRes"}) version=self.__createElement("version", parentNode=responseBody, text="1.0.1") instId=self.__createElement("instId", parentNode=responseBody, text=instId) certId=self.__createElement("certId", parentNode=responseBody, text=certId) errorCode=self.__createElement("errorCode", parentNode=responseBody, text=errorCode) errorMessage=self.__createElement("errorMessage", parentNode=responseBody, text=errorMessage) totalNum=self.__createElement("totalNum", parentNode=responseBody, text=str(totalNum)) curPageNum=self.__createElement("curPageNum", parentNode=responseBody, text=str(itemCount)) iFundDetailList=self.__createElement("iFundDetailList", parentNode=responseBody) for index in range(beginPos, endPos): item=self.__createElement("item", parentNode=iFundDetailList) self.__createElement("fundComNo", parentNode=item, text=index + 1) self.__createElement("productNo", parentNode=item, text=str(100000+index + 1)) self.__createElement("fundCode", parentNode=item, text='%06d' % (300+index + 1)) self.__createElement("fundName", parentNode=item, text="广发天天红货币"+str(index + 1)) self.__createElement("fundType", parentNode=item, text='%03d' % (random.randint(1,9))) self.__createElement("feesType", parentNode=item, text="0") self.__createElement("shareType", parentNode=item, text="0") self.__createElement("state", parentNode=item, text=str(random.randint(1,9))) self.__createElement("millionOfIncome", parentNode=item, text='{0:.4f}'.format(1 + random.random())) self.__createElement("sevenIncome", parentNode=item, text='{0:.4f}'.format(3 + random.random())) self.__createElement("fundsMon", parentNode=item, text='{0:.4f}'.format(random.random())) self.__createElement("fundDate", parentNode=item, text=util.date2Str(format="%Y-%m-%d")) signedMessage=self.__saveAndSign("FIQRes") return signedMessage
def _createQueryAccountRegistResultResponse(self, requestDict, expectationDict): root=self.__createElement('SoEv', parentNode=self.doc) message=self.__createElement('Message', parentNode=root, attrDict={"id":util.date2Str()}) responseBody=self.__createElement('ARQRes', parentNode=message, attrDict={"id":util.date2Str()}) instId=requestDict.get('instId', 'CGB(CGBCC)') certId=requestDict.get('certId', '0001') channelSeq=requestDict.get('channelSeq', '123456789009877782') errorCode=expectationDict.get('errorCode', '0000') errorMessage=expectationDict.get('errorMessage', '开户结果查询成功') dealRes=expectationDict.get('dealRes', '0') accountNo=expectationDict.get('accountNo', None) certNo=expectationDict.get('certNo', None) cusName=expectationDict.get('cusName', None) phoneNo=expectationDict.get('phoneNo', None) cardNo=expectationDict.get('cardNo', None) self.__createElement("version", parentNode=responseBody, text="1.0.1") self.__createElement("instId", parentNode=responseBody, text=instId) self.__createElement("certId", parentNode=responseBody, text=certId) self.__createElement("channelSeq", parentNode=responseBody, text=channelSeq) self.__createElement("errorCode", parentNode=responseBody, text=errorCode) self.__createElement("errorMessage", parentNode=responseBody, text=errorMessage) self.__createElement("DealRes", parentNode=responseBody, text=dealRes) self.__createElement("accountNo", parentNode=responseBody, text=accountNo) self.__createElement("certNo", parentNode=responseBody, text=certNo) self.__createElement("cusName", parentNode=responseBody, text=cusName) self.__createElement("phoneNo", parentNode=responseBody, text=phoneNo) self.__createElement("cardNo", parentNode=responseBody, text=cardNo) signedMessage=self.__saveAndSign("ARQRes") return signedMessage
def _createFundRedeemResponse(self, requestDict, expectationDict): root=self.__createElement('SoEv', parentNode=self.doc) message=self.__createElement('Message', parentNode=root, attrDict={"id":util.date2Str()}) responseBody=self.__createElement('FRRes', parentNode=message, attrDict={"id":util.date2Str()}) instId=requestDict.get('instId', 'CGB(CGBCC)') certId=requestDict.get('certId', '0001') channelSeq=requestDict.get('channelSeq', '123456789009877782') errorCode=expectationDict.get('errorCode', '0000') errorMessage=expectationDict.get('errorMessage', '基金赎回成功') dealRes=expectationDict.get('dealRes', '0') self.__createElement("version", parentNode=responseBody, text="1.0.1") self.__createElement("instId", parentNode=responseBody, text=instId) self.__createElement("certId", parentNode=responseBody, text=certId) self.__createElement("channelSeq", parentNode=responseBody, text=channelSeq) self.__createElement("errorCode", parentNode=responseBody, text=errorCode) self.__createElement("errorMessage", parentNode=responseBody, text=errorMessage) self.__createElement("dealRes", parentNode=responseBody, text=dealRes) self.__createElement("bussDate", parentNode=responseBody, text=util.date2Str(format='%Y%m%d')) signedMessage=self.__saveAndSign("FRRes") return signedMessage
def getResponse(self, requestDict, expectationDict): if expectationDict is None: expectationDict={} for value in expectationDict.values(): if value.find('EXCEPTION') >=0: print 'Raise an exception to match expectation' raise Exception('Raise exception') merchId=expectationDict.get('merchId', '0000323') actSttlmAmt=expectationDict.get('actSttlmAmt', '100.00') bizId=expectationDict.get('bizId', '20150908112353201') authId=expectationDict.get('authId', '010258911150722185225155BLLAmrYer') signInfo=expectationDict.get('signInfo', '7da3d117188e94c2dcdd38fd2df45c9a') state=expectationDict.get('state', '02') txId=expectationDict.get('txId', 'CEX150819141309187461368552') amount=expectationDict.get('amount', '100.00') respDescription=expectationDict.get('respDescription', 'success') bankId=expectationDict.get('bankId', '0104') cardTp=expectationDict.get('cardTp', '01') paymentTp=expectationDict.get('paymentTp', '02') classObj=expectationDict.get('class', 'com.creditease.ns.adapter.fastpay.data.FastPayNoAccountCardResponse') completeTime=expectationDict.get('completeTime', util.date2Str(format='%Y%m%d%H%M%S')) respCode=expectationDict.get('respCode', '100001') resDict={} resDict['merchId']=merchId resDict['actSttlmAmt']=actSttlmAmt resDict['bizId']=bizId resDict['authId']=authId resDict['signInfo']=signInfo resDict['state']=state resDict['txId']=txId resDict['amount']=amount resDict['respDescription']=respDescription resDict['bankId']=bankId resDict['cardTp']=cardTp resDict['paymentTp']=paymentTp resDict['classObj']=classObj resDict['completeTime']=completeTime resDict['respCode']=respCode jsonStr=json.dumps(resDict) return jsonStr
def getResponse(self, requestDict, expectationDict): if expectationDict is None: expectationDict={} for value in expectationDict.values(): if value.find('EXCEPTION') >=0: print 'Raise an exception to match expectation' raise Exception('Raise exception') envelope=self.__createElement('soap:Envelope', parentNode=self.doc, attrDict={"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/"}) body=self.__createElement('soap:Body', parentNode=envelope) response=self.__createElement('ns1:singlePaymentResponse', parentNode=body, attrDict={"xmlns:ns1":"http://impl.channel.adapter.ns.creditease.com/"}) returnNode=self.__createElement('return', parentNode=response) amount=expectationDict.get('amount', requestDict.get('amount', '100.00')) bizId=expectationDict.get('bizId', requestDict.get('bizId', 'chu1311091522420070223')) failReason=expectationDict.get('failReason', '0') merchId=expectationDict.get('merchId', requestDict.get('merchId', '0000323')) respCode=expectationDict.get('respCode', '0000') respDescription=expectationDict.get('respDescription', 'success') state=expectationDict.get('state', '01') completeTime=expectationDict.get('completeTime', util.date2Str(format='%Y-%m-%d %H:%M:%S')) txId=expectationDict.get('txId', 'CEX150825104635190462133038') signInfo=expectationDict.get('signInfo', '166605404c302c36882a83dca4f2fd00') self.__createElement("amount", parentNode=returnNode, text=amount) self.__createElement("bizId", parentNode=returnNode, text=bizId) self.__createElement("failReason", parentNode=returnNode, text=failReason) self.__createElement("merchId", parentNode=returnNode, text=merchId) self.__createElement("respCode", parentNode=returnNode, text=respCode) self.__createElement("respDescription", parentNode=returnNode, text=respDescription) self.__createElement("state", parentNode=returnNode, text=state) self.__createElement("completeTime", parentNode=returnNode, text=completeTime) self.__createElement("txId", parentNode=returnNode, text=txId) self.__createElement("signInfo", parentNode=returnNode, text=signInfo) xmlContent=self.doc.toprettyxml(indent=' ') print xmlContent return xmlContent
def _createErroResponse(self, requestDict, expectationDict): root=self.__createElement('SoEv', parentNode=self.doc) message=self.__createElement('Message', parentNode=root, attrDict={"id":util.date2Str()}) errorBody=self.__createElement('Error', parentNode=message) instId=requestDict.get('instId', 'CGB(CGBCC)') certId=requestDict.get('certId', '0001') errorCode=expectationDict.get('errorCode', '1000') errorMessage=expectationDict.get('errorMessage', '操作失败') dealRes=expectationDict.get('errorDetail', 'error detail') dealRes=expectationDict.get('vendorCode', '6789') self.__createElement("version", parentNode=responseBody, text="1.0.1") self.__createElement("instId", parentNode=responseBody, text=instId) self.__createElement("certId", parentNode=responseBody, text=certId) self.__createElement("errorCode", parentNode=responseBody, text=errorCode) self.__createElement("errorMessage", parentNode=responseBody, text=errorMessage) self.__createElement("errorDetail", parentNode=responseBody, text=dealRes) self.__createElement("vendorCode", parentNode=responseBody, text=dealRes) signedMessage=self.__saveAndSign("FRRes") return signedMessage