def testChargeAndCancel(self,data): '''储值撤销场景:储值预览->储值提交->储值撤销''' '''--------------------------交易预览接口----------------------''' biz_id_01 = scripts.rndTimeStr() + '007' data['ChargePreview']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['ChargePreview'],appid=data['Appid'], desc=data['Desc'],url=data['ChargePreviewUrl'],v=data['V'] ) self.assertEquals(res['errcode'], 0, res['errmsg']) #交易预览断言 '''--------------------------交易提交接口----------------------''' data['ChargeCommit']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 commitResult = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['ChargeCommit'],appid=data['Appid'], desc=data['Desc'],url=data['ChargeCommitUrl'],v=data['V'] ) self.assertEquals(commitResult['errcode'], 0, commitResult['errmsg']) #交易提交断言 '''--------------------------交易撤销接口----------------------''' data['ChargeCancel']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 cancelResult = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['ChargeCancel'],appid=data['Appid'], desc=data['Desc'],url=data['ChargeCancelUrl'],v=data['V'] ) self.assertEquals(cancelResult['errcode'], 0, cancelResult['errmsg']) #交易撤销断言
def testCouponSendAndCancel(self, data): '''发券并撤销业务场景:发券->撤销''' # 场景顺序执行 biz_id_01 = scripts.rndTimeStr() + '010' # ----修改数据---- data['CouponSend']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 sendResult = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['CouponSend'], appid=data['Appid'], desc=data['Desc'], url=data['CouponSendUrl']) self.assertEqual(sendResult['errcode'], 0, sendResult['errmsg']) #发券断言 #撤销发券 data['CouponCancel']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 cancelResult = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['CouponCancel'], appid=data['Appid'], desc=data['Desc'], url=data['CouponCancelUrl']) #断言 self.assertEqual(cancelResult['errcode'], 0, cancelResult['errmsg']) #撤销发券断言
def testDealAndRollback(self,data): '''消费并冲正场景: 交易预览->交易冲正''' #交易预览 biz_id_01 = scripts.rndTimeStr() +'012' data['DealPreview']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 reviewResult = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['DealPreview'],appid=data['Appid'], desc=data['Desc'],url=data['DealPreviewUrl'] ) #断言 self.assertEqual(reviewResult['errcode'],0,reviewResult['errmsg']) #消费预览断言 #交易冲正 data['DealRollback']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 rollResult = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['DealRollback'],appid=data['Appid'], desc=data['Desc'],url=data['DealRollbackUrl'] ) #断言 self.assertEqual(rollResult['errcode'],0,rollResult['errmsg']) #交易冲正断言 #交易提交,冲正之后不允许提交3032交易异常 data['DealCommit']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 commitResult = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['DealCommit'],appid=data['Appid'], desc=data['Desc'],url=data['DealCommitUrl'] ) #断言 self.assertEqual(commitResult['errcode'],3032,commitResult['errmsg']) #交易冲正断言
def testGradeEditAndDesc(self,data): '''会员升级降级:储值调整增加200->会员升级->储值调整减少200''' # 整合数据,调用接口,获取返回结果 Result = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['ChargeChangeAdd'],appid=data['Appid'], desc=data['Desc'],url=data['ChargeChangeUrl'],Appkey=data['Appkey'] ) self.assertEqual(Result['errcode'], 0, Result['errmsg']) #储值调整接口断言 #会员升级 # 整合数据,调用接口,获取返回结果 editResult = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['GradeEdit'],appid=data['Appid'], desc=data['Desc'],url=data['GradeEditUrl'],Appkey=data['Appkey'] ) self.assertEqual(editResult['errcode'], 0, editResult['errmsg']) #会员升级接口断言 #储值调整 减少200 # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface( instance=HttpWebRequest(),instance_pro='post',data=data['ChargeChange'],appid=data['Appid'], desc=data['Desc'],url=data['ChargeChangeUrl'],Appkey=data['Appkey'] ) #断言 self.assertEqual(res['errcode'],0,res['errmsg']) #储值调整接口减少200断言
def testCouponSendAndAdjust(self, data): '''发券并手工调账核销券:发券->获取用户账户信息->手工调账核销券''' #发券 biz_id_01 = scripts.rndTimeStr() + '013' # ----修改数据---- data['CouponSend']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 sendResult = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['CouponSend'], appid=data['Appid'], desc=data['Desc'], url=data['CouponSendUrl']) self.assertEqual(sendResult['errcode'], 0, sendResult['errmsg']) #发送券接口断言 #获取用户账户信息 # 整合数据,调用接口,获取返回结果 accountResult = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserAccount'], appid=data['Appid'], desc=data['Desc'], url=data['UserAccountUrl']) #接口断言 self.assertEqual(accountResult['errcode'], 0, accountResult['errmsg']) #获取用户账户信息接口断言 self.assertTrue(accountResult['res'], accountResult['errmsg']) coupon_id_02 = accountResult['res'][0]['coupons'][0]['coupon_ids'][ 0] #券id结构取值 #手工调账核销券 data['CouponAdjust']['coupon_ids'].append( coupon_id_02) #将上一步查到的id传给核销接口 # 整合数据,调用接口,获取返回结果 adjustResult = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['CouponAdjust'], appid=data['Appid'], desc=data['Desc'], url=data['CouponAdjustUrl']) #断言 self.assertEqual(adjustResult['errcode'], 0, adjustResult['errmsg']) #手工调帐核销断言 self.assertEqual(adjustResult['res']['result'], 'SUCCESS', adjustResult['res']['result']) #手工调帐返回结果断言
def testChargeAndReceipt(self, data): '''储值并开发票场景:储值预览->储值提交->可开发票查询->开发票''' '''step-1--------------------------交易预览接口----------------------''' biz_id_01 = scripts.rndTimeStr() + '007' data['ChargePreview']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ChargePreview'], appid=data['Appid'], desc=data['Desc'], url=data['ChargePreviewUrl']) self.assertEquals(res['errcode'], 0, res['errmsg']) #交易预览断言 '''step-2--------------------------交易提交接口----------------------''' data['ChargeCommit']['biz_id'] = biz_id_01 # 整合数据,调用接口,获取返回结果 commitResult = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ChargeCommit'], appid=data['Appid'], desc=data['Desc'], url=data['ChargeCommitUrl']) self.assertEquals(commitResult['errcode'], 0, commitResult['errmsg']) #交易提交断言 '''step-3--------------------------用户可开发票查询接口----------------------''' # 整合数据,调用接口,获取返回结果 selectResult = scripts.loadtestInterface( instance=HttpWebRequest(), instance_pro='post', data=data['ChargeReceiptstat'], appid=data['Appid'], desc=data['Desc'], url=data['ChargeReceiptstatUrl']) self.assertEquals(selectResult['errcode'], 0, selectResult['errmsg']) self.assertTrue(selectResult['res']) '''step-4--------------------------开发票接口----------------------''' data['ChargeReceiptbatch']['biz_id'] = str(biz_id_01) # 整合数据,调用接口,获取返回结果 batchResult = scripts.loadtestInterface( instance=HttpWebRequest(), instance_pro='post', data=data['ChargeReceiptbatch'], appid=data['Appid'], desc=data['Desc'], url=data['ChargeReceiptbatchUrl']) self.assertEquals(batchResult['errcode'], 0, batchResult['errmsg']) self.assertTrue(batchResult['res']['result'] == "开发票成功")
def testActivityGetuserthumbuplog(self, data): '''活动接口:查询用户参与的集赞活动/activity/getuserthumbuplog''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['Getuserthumbuplog'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # me,he = scripts.MultipartPartData( # req=data['Getuserthumbuplog'], # appid = data['Appid'], # v = 2.0, # ts = 1, # sig = 1, # boundary = '----WebKitFormBoundary7MA4YWxkTrZu0gW' # ) # interface = HttpWebRequest() # interface.url = data['Url'] # interface.payload = me # interface.headers = he # res = interface.post #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) #断言 self.assertTrue(res['res'])
def testCouponOtherSendAndCancel(self, data): '''异业营销发券并撤销场景: 获取异业营销活动列表->异业营销发券->异业营销券码核销''' # 获取异业营销活动列表 # 整合数据,调用接口,获取返回结果 result = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['OtherList'], appid=data['Appid'], desc=data['Desc'], url=data['OtherListUrl']) self.assertTrue(result['res']) aid = str(result['res'][0]['id']) # 异业营销发券 biz_id_01 = scripts.rndTimeStr() + '011' #----------参数给值------------# data['OtherSend']['biz_id'] = biz_id_01 #唯一值 data['OtherSend']['aid'] = aid #活动id # 整合数据,调用接口,获取返回结果 sendresult = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['OtherSend'], appid=data['Appid'], desc=data['Desc'], url=data['OtherSendUrl']) self.assertEqual(sendresult['errcode'], 0, sendresult['errmsg']) #异业营销发券接口断言 coupon_code = sendresult['res']['coupon_codes'][0]['code'] #异业营销券码核销 data['OtherVerification']['coupon_code'] = coupon_code # 整合数据,调用接口,获取返回结果 cancelresult = scripts.loadtestInterface( instance=HttpWebRequest(), instance_pro='post', data=data['OtherVerification'], appid=data['Appid2'], desc=data['Desc'], url=data['OtherVerificationUrl'], Appkey=data['Appkey2']) self.assertEqual(cancelresult['errcode'], 0, cancelresult['errmsg']) #断言
def testUserGrade(self, data): """查询会员等级信息/user/grade""" res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserGrade'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testUserCouponlist(self, data): """会员全部券接口/user/couponlist""" res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserCouponList'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testUserBindPhone(self, data): """绑定/修改手机号/user/bindphone""" res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['BindPhone'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testUserGetc2uInfo(self, data): '''用户接口:根据券获取用户账户信息/user/getc2uinfo''' # 根据券获取用户账户信息 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['Getc2uinfo'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) #断言获取已过期优惠券
def testConsumeuser(self, data): '''查询接口:用户消费记录/consume/user''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ConsumeUser'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testChargelist(self, data): '''查询接口:储值记录列表/charge/list''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ChargeList'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testProductlistbyuser(self, data): '''菜品接口:查询会员点菜记录/product/listbyuser''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ProductListByUser'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testPosshopcredit(self, data): '''硬pos获取用户的积分规则/pos/shopcredit''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['PosShopcredit'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 由于线上,硬pos,测试商家无法,使用,因此断言未登录10009 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testCoupongift(self, data): '''券转赠接口/coupon/gift断言30013,该券已转赠过不能重复提交''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['CouponGift'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 30013, res['errmsg'])
def testPosChargedetail(self, data): '''储值模块:查询指定流水号储值记录详情/pos/chargedetail''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['PosChargeDetail'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 10009, res['errmsg'])
def testTagtouser(self, data): '''用户接口:用户增加标签/tag/touser''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['TagToUser'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testUseredit(self, data): '''用户接口:修改会员信息/user/edit''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserEdit'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testCouponoverdue(self, data): '''查询接口:/coupon/overdue''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['CouponOverdue'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testUserPhoneCard(self, data): """手机开卡/user/phonecard""" res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserPhoneCard'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) # 断言 self.assertEqual(res['errcode'], 0, res['errmsg']) self.assertTrue(res['res']['result'] == 'SUCCESS')
def testUsercardinfo(self, data): '''用户接口:查询电子卡接口/user/cardinfo''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserCardinfo'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testUserGetUseCoupon(self, data): '''用户接口:获取已过期优惠券user/getoverduecoupons''' # 获取已过期优惠券 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['OverDueCoupon'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) #断言获取已过期优惠券
def testChargetoday(self, data): '''储值模块:当日储值统计/charge/today''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ChargeToDay'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) self.assertTrue(res['res'].has_key('shop_offline'))
def testChargeReceipt(self, data): '''储值模块:储值是否开发票/charge/receipt''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ChargeReceipt'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) self.assertTrue(res['res']['result'] == 'SUCCESS')
def testChargeRule(self, data): '''储值模块:查看门店储值规则设置/charge/rule''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ChargeRule'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) self.assertTrue(res['res'].has_key('content'))
def testUserCreditListI(self, data): '''用户接口:用户积分记录/user/creditlist''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserCreditList'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) #断言,用户积分记录 self.assertTrue(res['res'], "查询结果为空") #查询res为空
def testUserugetinfo(self, data): '''用户接口:unionid查询用户/user/ugetinfo''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['UserUgetinfo'], appid=data['Appid'], desc=data['Desc'], url=data['Url'], Appkey=data['Appkey']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg'])
def testChargeView(self, data): '''储值模块:储值记录详情/charge/view''' # 整合数据,调用接口,获取返回结果 res = scripts.loadtestInterface(instance=HttpWebRequest(), instance_pro='post', data=data['ChargeView'], appid=data['Appid'], desc=data['Desc'], url=data['Url']) #断言 self.assertEqual(res['errcode'], 0, res['errmsg']) self.assertTrue(res['res'].has_key('status'))