def test_系统模块(self,*lists): mode=dict(zip(r.p,list(lists))) #列表转字典 url=mode['url']; method=mode['method']; response=r.responsedict(mode['response']); sendcode={} del mode['method']; del mode['url']; del mode['response']; mode['phone']='+'+str(mode['phone']) if mode['annotation']=='注册' or mode['annotation']=='修改支付密码' or mode['annotation']=='忘记密码更改密码': sendcode['phone']=mode['phone'] code__url=None; if mode['annotation']=='注册': code__url="send_register_code" elif mode['annotation']=='修改支付密码': mode['token']=files.getconfig('token') if mode['token']=='' else mode['token'] mode['appid']='F55EF6EC-5D84-4B52-95A7-E34FA365EFED' sendcode['token']=mode['token'] code__url="send_reset_paypassword_code_url"; elif mode['annotation']=='忘记密码更改密码': code__url="forget_password"; messeage=json.loads(httpRequest.requestHttp.returnResponse(url=files.phone_code(code__url),param=sendcode,method='post')); code=input("请输入手机收到的"+mode['annotation']+"验证码") if not messeage['success']: self.assertTrue(messeage['success'],"发送"+mode['annotation']+"验证码,错误为"+messeage['msg']) mode['code']=code elif mode['annotation']=='登陆': mode['username']='******'+str(mode['username']) mode['appid']='F55EF6EC-5D84-4B52-95A7-E34FA365EFED' elif mode['annotation']=='设置支付密码'or mode['annotation']=='验证支付密码是否正确': mode['token']=files.getconfig('token') if mode['token']=='' else mode['token'] returnstr=json.loads(httpRequest.requestHttp.returnResponse(url=url,param=r.getpar(mode),method=method)); if mode['annotation']=='登陆' and returnstr['success']==True: files.config(str(returnstr)) responsekey=list(response.keys()) responsevalue=list(response.keys()) strkey= returnstr.keys(); for x in range(len(response.keys())): if responsekey[x] in strkey: if type(returnstr[responsekey[x]])==dict: self.assertEqual(eval(response[responsekey[x]]),returnstr[responsekey[x]],mode['annotation']+'内容不一样.系统返回的msg为:'+str(returnstr['msg'])) elif type(returnstr[responsekey[x]])==list: for y in returnstr[responsekey[x]]: for i in eval(response[responsekey[x]]): #print(i in y.keys()) if i in y.keys(): if(eval(response[responsekey[x]])[i] in list(y.values())): self.assertIn(eval(response[responsekey[x]])[i], list(y.values())) else: self.assertIs(i,y.keys(),mode['annotation']+'键不存在.系统返回的msg为:'+str(returnstr['msg'])) #print(list(eval(response[responsekey[x]]).keys()) , list(y.keys())) #self.assertIn(eval(response[responsekey[x]]),returnstr[responsekey[x]],'不存在返回值中.系统返回的msg为:'+str(returnstr['msg'])) else: self.assertEqual(response[responsekey[x]].upper(),str(returnstr[responsekey[x]]).upper(),mode['annotation']+'返回值不一致.系统返回的msg为:'+str(returnstr['msg'])) else: self.assertIn(responsekey[x],strkey,mode['annotation']+'键不存在.系统返回的msg为:'+str(returnstr['msg']))
def test_转账模块(self,*lists): mode=dict(zip(r.p,list(lists))) #列表转字典 url=mode['url']; method=mode['method']; response=r.responsedict(mode['response']); del mode['method']; del mode['url']; del mode['response']; mode['token']=files.getconfig('token') if mode['token']=='' else mode['token'] if mode['annotation']=='获取转账的费用费率等信息(锁汇)' or mode['annotation']=='转账': for k,v in mode.items(): if v!='' and type(v)==str: if v[0]=='{' and v[-1]=='}': #print(k,eval(v)) mode[k]=eval(v) if mode['annotation']=='汇率是否超时' or mode['annotation']=='转账': mode['action_id']=files.getconfig('action_id') if mode['action_id']=='' else mode['action_id'] if mode['annotation']=='获取转账详情': mode['transfer_id']=files.getconfig('transfer_id') if mode['transfer_id']=='' else mode['transfer_id'] returnstr=json.loads(httpRequest.requestHttp.returnResponse(url=url,param=r.getpar(mode),method=method)); if mode['annotation']=='获取转账的费用费率等信息(锁汇)'and returnstr['success']==True: files.appendconfig({'action_id':returnstr['action_id']}) if mode['annotation']=='转账'and returnstr['success']==True: files.appendconfig({'transfer_id':returnstr['transfer']['id']}) responsekey=list(response.keys()) responsevalue=list(response.keys()) strkey= returnstr.keys(); for x in range(len(response.keys())): if responsekey[x] in strkey: if type(returnstr[responsekey[x]])==dict: self.assertEqual(eval(response[responsekey[x]]),returnstr[responsekey[x]],mode['annotation']+'内容不一样.系统返回的msg为:'+str(returnstr['msg'])) elif type(returnstr[responsekey[x]])==list: for y in returnstr[responsekey[x]]: for i in eval(response[responsekey[x]]): #print(i in y.keys()) if i in y.keys(): if(eval(response[responsekey[x]])[i] in list(y.values())): self.assertIn(eval(response[responsekey[x]])[i], list(y.values())) else: self.assertIs(i,y.keys(),mode['annotation']+'键不存在.系统返回的msg为:'+str(returnstr['msg'])) #print(list(eval(response[responsekey[x]]).keys()) , list(y.keys())) #self.assertIn(eval(response[responsekey[x]]),returnstr[responsekey[x]],'不存在返回值中.系统返回的msg为:'+str(returnstr['msg'])) else: self.assertEqual(response[responsekey[x]].upper(),str(returnstr[responsekey[x]]).upper(),mode['annotation']+'返回值不一致.系统返回的msg为:'+str(returnstr['msg'])) else: self.assertIn(responsekey[x],strkey,mode['annotation']+'键不存在.系统返回的msg为:'+str(returnstr['msg']))
def test_日常账户模块(self, *lists): mode = dict(zip(r.p, list(lists))) #列表转字典 url = mode['url'] method = mode['method'] response = r.responsedict(mode['response']) del mode['method'] del mode['url'] del mode['response'] mode['token'] = files.getconfig( 'token') if mode['token'] == '' else mode['token'] if mode['annotation'] == '获取日常账户流水 / 日常账户详情': mode['page_index'] = 1 mode['page_size'] = 5 mode['account_id'] = files.getconfig( 'account_id' ) if mode['account_id'] == '' else mode['account_id'] if mode['annotation'] == '获取单个日常账户': mode['currency_id'] = files.getconfig( 'currency_id' ) if mode['currency_id'] == '' else mode['currency_id'] if mode['annotation'] == '设置日常账户别名': mode['account_id'] = files.getconfig( 'account_id' ) if mode['account_id'] == '' else mode['account_id'] returnstr = json.loads( httpRequest.requestHttp.returnResponse(url=url, param=r.getpar(mode), method=method)) if mode['annotation'] == '获取omipay日常账户列表' and returnstr[ 'success'] == True: files.appendconfig({ 'account_id': returnstr['common_accounts'][0]['id'], 'currency_id': returnstr['common_accounts'][0]['currency_id'] }) responsekey = list(response.keys()) responsevalue = list(response.keys()) strkey = returnstr.keys() for x in range(len(response.keys())): if responsekey[x] in strkey: if type(returnstr[responsekey[x]]) == dict: self.assertEqual( eval(response[responsekey[x]]), returnstr[responsekey[x]], mode['annotation'] + '内容不一样.系统返回的msg为:' + str(returnstr['msg'])) elif type(returnstr[responsekey[x]]) == list: for y in returnstr[responsekey[x]]: for i in eval(response[responsekey[x]]): #print(i in y.keys()) if i in y.keys(): if (eval(response[responsekey[x]])[i] in list(y.values())): self.assertIn( eval(response[responsekey[x]])[i], list(y.values())) else: self.assertIs( i, y.keys(), mode['annotation'] + '键不存在.系统返回的msg为:' + str(returnstr['msg'])) #print(list(eval(response[responsekey[x]]).keys()) , list(y.keys())) #self.assertIn(eval(response[responsekey[x]]),returnstr[responsekey[x]],'不存在返回值中.系统返回的msg为:'+str(returnstr['msg'])) else: self.assertEqual( response[responsekey[x]].upper(), str(returnstr[responsekey[x]]).upper(), mode['annotation'] + '返回值不一致.系统返回的msg为:' + str(returnstr['msg'])) else: self.assertIn( responsekey[x], strkey, mode['annotation'] + '键不存在.系统返回的msg为:' + str(returnstr['msg']))
def test_外部账户模块(self, *lists): mode = dict(zip(r.p, list(lists))) #列表转字典 url = mode['url'] method = mode['method'] response = r.responsedict(mode['response']) del mode['method'] del mode['url'] del mode['response'] mode['token'] = files.getconfig( 'token') if mode['token'] == '' else mode['token'] if mode['annotation'] == '获取外部账户流水': mode['page_index'] = 1 mode['page_size'] = 5 elif mode['annotation'] == '设置外部账户别名': mode['account_id'] = files.getconfig( 'out_accounts_id' ) if mode['account_id'] == '' else mode['account_id'] elif mode['annotation'] == '增加外部账户': for k, v in mode.items(): if v != '' and type(v) == str: if v[0] == '{' and v[-1] == '}': #print(k,eval(v)) mode[k] = eval(v) elif mode['annotation'] == '解除绑定': mode['account_id'] = files.getconfig( 'out_accounts_id' ) if mode['account_id'] == '' else mode['account_id'] returnstr = json.loads( httpRequest.requestHttp.returnResponse(url=url, param=r.getpar(mode), method=method)) if mode['annotation'] == '获取外部账户列表' and returnstr['success'] == True: files.appendconfig( {'out_accounts_id': returnstr['out_accounts'][0]['id']}) responsekey = list(response.keys()) responsevalue = list(response.keys()) strkey = returnstr.keys() for x in range(len(response.keys())): if responsekey[x] in strkey: if type(returnstr[responsekey[x]]) == dict: self.assertEqual( eval(response[responsekey[x]]), returnstr[responsekey[x]], mode['annotation'] + '内容不一样.系统返回的msg为:' + str(returnstr['msg'])) elif type(returnstr[responsekey[x]]) == list: for y in returnstr[responsekey[x]]: for i in eval(response[responsekey[x]]): #print(i in y.keys()) if i in y.keys(): if (eval(response[responsekey[x]])[i] in list(y.values())): self.assertIn( eval(response[responsekey[x]])[i], list(y.values())) else: self.assertIs( i, y.keys(), mode['annotation'] + '键不存在.系统返回的msg为:' + str(returnstr['msg'])) #print(list(eval(response[responsekey[x]]).keys()) , list(y.keys())) #self.assertIn(eval(response[responsekey[x]]),returnstr[responsekey[x]],'不存在返回值中.系统返回的msg为:'+str(returnstr['msg'])) else: self.assertEqual( response[responsekey[x]].upper(), str(returnstr[responsekey[x]]).upper(), mode['annotation'] + '返回值不一致.系统返回的msg为:' + str(returnstr['msg'])) else: self.assertIn( responsekey[x], strkey, mode['annotation'] + '键不存在.系统返回的msg为:' + str(returnstr['msg']))