예제 #1
0
    def testbiaoservernewhulogin(self, data):
        '''获得活动信息->预登录接口->polling用户登录session信息->下单接口->polling订单支付状态->出货接口'''

        '''--------------------------预登录接口需登录----------------------'''
        # 整合数据,调用接口,获取返回结果
        #预登录接口
        # data['standardPrepareLogindata']['params']['machineCode'] = machineCode
        #
        # res = scripts.loadtestInterface(
        #     instance=HttpWebRequest(),
        #     instance_pro='post',
        #     data=json.dumps(data['standardPrepareLogindata']),
        #     desc=data['Desc'],
        #     url=data['GameUrl']
        # )

        # sessionUuid = reslogin['data']['sessionUuid']
        # print 'sessionUuid: ' + sessionUuid
        # #断言
        # self.assertEqual(reslogin['code'],0,reslogin['msg'])
        # print reslogin['data']['qrCodeUrl']
        #
        sleep(30)


        '''--------------------------获得活动信息----------------------'''
        # 整合数据,调用接口,获取返回结果
        #获得活动信息
        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardFindActivitydata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        #断言
        machineCode = res['data']['machineCode']
        activityPlanId = res['data']['activityPlanId']
        activityId = res['data']['activityId']
        activityType = res['data']['activityType']
        print activityType
        print '各数据信息:' +'machineCode: '+ machineCode+'  ' +'activityPlanId: '+ activityPlanId+'  ' +'activityId: '+activityId
        self.assertEqual(res['code'],0,res['msg'])#断言
        self.assertEqual(res['data']['activityType'], 1, res['msg'])


        '''--------------------------获取商品信息----------------------'''
        # 整合数据,调用接口,获取返回结果
        #下单接口
        # data['standardgetSamplingNew']['machineCode'] = machineCode

        res = scripts.loadtestInterface(
            instance=HttpWebRequestget(),
            instance_pro='post',
            data='------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"machineCode\"\r\n\r\n18383061\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--',
            desc=data['Desc'],
            url=data['GoodsUrl']
        )

        newgoodid = res['data'][0]['id']
        newgoodcode = res['data'][0]['code']
        newsellerid = res['data'][0]['sellerId']
        newshopId = res['data'][0]['shopId']
        newsessionKey = res['data'][0]['sessionKey']
        newnum = res['data'][0]['num']
        print newgoodid,newgoodcode,newsellerid,newshopId,newsessionKey,newnum
        #断言
        self.assertEqual(res['code'],0,res['msg'])

        '''--------------------------polling用户登录session信息----------------------'''
        # 整合数据,调用接口,获取返回结果
        #polling用户登录session信息
        data['standardSessionPollingdata']['params']['sessionUuid'] = machineCode

        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardSessionPollingdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        #断言
        userNick = res['data']['userNick']
        canOrder = res['data']['canOrder']
        goodsId = res['data']['goodsId']
        goodsCode = res['data']['goodsCode']
        isScanned = res['data']['isScanned']
        countGoods = res['data']['countGoods']
        sellerId = res['data']['sellerId']

        print userNick
        print canOrder
        print goodsId
        print goodsCode
        print isScanned
        print countGoods
        print sellerId
        #断言
        self.assertEqual(res['code'],0,res['msg'])
        self.assertTrue(res['data']['userNick'])
        self.assertEqual(res['data']['canOrder'],True,res['msg'])
        self.assertEqual(res['data']['countGoods'], True, res['msg'])
        self.assertEqual(res['data']['logged'],True,res['msg'])
        self.assertTrue(res['data']['goodsId'])
        self.assertTrue(res['data']['goodsCode'])
        self.assertTrue(res['data']['sellerId'])
        self.assertEqual(res['data']['isScanned'], True, res['msg'])


        '''--------------------------下单接口----------------------'''
        # 整合数据,调用接口,获取返回结果
        #下单接口
        data['standardOrderdata']['params']['sessionUuid'] = machineCode

        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardOrderdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        channelIds = res['data']['goods'][0]['channelIds'][0]
        payQrcodeImage = res['data']['payQrcodeImage']
        print 'channelIds:'+channelIds
        print 'payQrcodeImage: '+payQrcodeImage
        #断言
        self.assertEqual(res['code'],0,res['msg'])
        self.assertEqual(res['data']['orderResult'],0,res['msg'])




        '''--------------------------polling订单支付状态----------------------'''
        # 整合数据,调用接口,获取返回结果
        #polling订单支付状态
        data['standardOrderPollingdata']['params']['sessionUuid'] = machineCode

        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardOrderPollingdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        # channelIds = res['data']['goods'][0]['channelIds'][0]
        # print 'channelIds:'+channelIds
        #断言
        self.assertEqual(res['code'],0,res['msg'])#断言
        self.assertEqual(res['data']['model'],True,res['msg'])

        '''--------------------------出货接口----------------------'''
        # 整合数据,调用接口,获取返回结果
        #出货接口
        data['standardShipmentdata']['params']['sessionUuid'] = machineCode
        data['standardShipmentdata']['params']['machineCode'] = machineCode
        data['standardShipmentdata']['params']['channelId'] = channelIds
        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardShipmentdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        #断言
        self.assertEqual(res['code'],0,res['msg'])#断言
예제 #2
0
    def testbiaoserverlogin(self, data):
        '''获得活动信息->预登录接口->polling用户登录session信息->下单接口->polling订单支付状态->出货接口'''

        '''--------------------------预登录接口需登录----------------------'''
        # 整合数据,调用接口,获取返回结果
        #预登录接口
        # data['standardPrepareLogindata']['params']['machineCode'] = machineCode
        #
        # res = scripts.loadtestInterface(
        #     instance=HttpWebRequest(),
        #     instance_pro='post',
        #     data=json.dumps(data['standardPrepareLogindata']),
        #     desc=data['Desc'],
        #     url=data['GameUrl']
        # )
        #
        # sessionUuid = reslogin['data']['sessionUuid']
        # print 'sessionUuid: ' + sessionUuid
        # #断言
        # self.assertEqual(reslogin['code'],0,reslogin['msg'])
        # print reslogin['data']['qrCodeUrl']
        #
        sleep(30)


        '''--------------------------获得活动信息----------------------'''
        # 整合数据,调用接口,获取返回结果
        #获得活动信息
        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardFindActivitydata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        #断言
        print type(res)
        machineCode = res['data']['machineCode']
        activityPlanId = res['data']['activityPlanId']
        activityId = res['data']['activityId']
        channelId = res['data']['channelId']
        activityType = res['data']['activityType']
        print '各数据信息:' +'machineCode: '+ machineCode+'  ' +'activityPlanId: '+ activityPlanId+'  ' +'activityId: '+activityId+'  ' +'channelId: '+channelId
        self.assertEqual(res['code'],0,res['msg'])#断言
        self.assertEqual(res['data']['activityType'], 0, res['msg'])

        '''--------------------------polling用户登录session信息----------------------'''
        # 整合数据,调用接口,获取返回结果
        #polling用户登录session信息
        data['standardSessionPollingdata']['params']['sessionUuid'] = machineCode

        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardSessionPollingdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )

        #断言
        userNick = res['data']['userNick']
        canOrder = res['data']['canOrder']
        goodsId = res['data']['goodsId']
        goodsCode = res['data']['goodsCode']
        isScanned = res['data']['isScanned']
        countGoods = res['data']['countGoods']
        sellerId  = res['data']['sellerId']
        print userNick
        print canOrder
        print goodsId
        print goodsCode
        print isScanned
        print countGoods
        print sellerId
        #断言
        self.assertEqual(res['code'],0,res['msg'])
        self.assertTrue(res['data']['userNick'])
        self.assertEqual(res['data']['canOrder'],True,res['msg'])
        self.assertEqual(res['data']['countGoods'], True, res['msg'])
        self.assertEqual(res['data']['logged'],True,res['msg'])
        self.assertTrue(res['data']['goodsId'])
        self.assertTrue(res['data']['goodsCode'])
        self.assertTrue(res['data']['sellerId'])
        self.assertEqual(res['data']['isScanned'], True, res['msg'])


        '''--------------------------下单接口----------------------'''
        # 整合数据,调用接口,获取返回结果
        #下单接口
        data['standardOrderdata']['params']['sessionUuid'] = machineCode

        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardOrderdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        channelIds = res['data']['goods'][0]['channelIds'][0]
        payQrcodeImage = res['data']['payQrcodeImage']
        print 'channelIds:'+channelIds
        print 'payQrcodeImage: '+payQrcodeImage
        #断言
        self.assertEqual(res['code'],0,res['msg'])
        self.assertEqual(res['data']['orderResult'],0,res['msg'])




        '''--------------------------polling订单支付状态----------------------'''
        # 整合数据,调用接口,获取返回结果
        #polling订单支付状态
        data['standardOrderPollingdata']['params']['sessionUuid'] = machineCode

        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardOrderPollingdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        # channelIds = res['data']['goods'][0]['channelIds'][0]
        # print 'channelIds:'+channelIds
        #断言
        self.assertEqual(res['code'],0,res['msg'])#断言
        self.assertEqual(res['data']['model'],True,res['msg'])

        '''--------------------------出货接口----------------------'''
        # 整合数据,调用接口,获取返回结果
        #出货接口
        data['standardShipmentdata']['params']['sessionUuid'] = machineCode
        data['standardShipmentdata']['params']['machineCode'] = machineCode
        data['standardShipmentdata']['params']['channelId'] = channelIds
        res = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            instance_pro='post',
            data=json.dumps(data['standardShipmentdata']),
            desc=data['Desc'],
            url=data['GameUrl']
        )
        #断言
        self.assertEqual(res['code'],0,res['msg'])#断言
예제 #3
0
        self.assertEqual(res['code'],0,res['msg'])#断言




if __name__=="__main__":

    suite = unittest.TestSuite()
    tests = [unittest.TestLoader().loadTestsFromTestCase(TestBGameScenario)]
    suite.addTests(tests)
    '''--------------------------预登录接口需登录----------------------'''
    # 整合数据,调用接口,获取返回结果
    # 预登录接口

    reslogin = scripts.loadtestInterface(
        instance=HttpWebRequest(),
        instance_pro='post',
        data='{"serviceName": "standardPrepareLogin","version": "1.0.0","params": {"machineCode": "18383061","loginType": 0,"operType":"1","ext": {"isVip": 1,"itemId": "bdaa0181cb9648b680ba6ca4c25d11c2","sessionKey": "61013020f71ce7d140b192f3280c377b81e828b6ec9584c3098056950","goodsCode": ""}}}',
        desc='预登录接口需登录',
        url='http://api.game.36solo.com/inno72/service/open'
    )

    filePath = os.path.join(gl.reportPath, 'gameReportnewlogin.html')  # 确定生成报告的路径
    # print filePath

    with file(filePath, 'wb') as fp:
        runner = HTMLTESTRunnerCN.HTMLTestRunner(
            stream=fp,
            title=u'点72标准游戏服务接口自动化测试报告',
            description=u'详细测试用例结果',  # 不传默认为空
            tester=u"sgao"  # 测试人员名字,不传默认为小强
예제 #4
0
    def testgameserver(self, data):
        '''生成二维码->获取登录信息->查看游戏列表->查看商品信息->下单->查看订单状态->出货后商品减量'''
        '''--------------------------生成二维码----------------------'''
        machineId = '19294124'
        # 整合数据,调用接口,获取返回结果
        #生成二维码接口
        # res = scripts.loadtestInterface(
        #     instance=HttpWebRequestnew(),
        #     instance_pro='post',
        #     data=data['CreateQrCodedata'],
        #     desc=data['Desc'],
        #     url=data['GameUrl']
        # )
        Suuidcode = res['data']['qrCodeUrl']
        print "TMURL:" + Suuidcode
        SUuidtoken = res['data']['sessionUuid']
        print "Token:" + SUuidtoken
        SUuidtokenNew = unicode.encode(SUuidtoken)
        #断言
        self.assertEqual(res['code'], 0, res['msg'])  #断言

        sleep(30)
        '''--------------------------获取登录信息----------------------'''
        Pdata = SUuidtokenNew
        eval(data['Pollingdata'])['params']['sessionUuid'] = Pdata

        # 整合数据,调用接口,获取返回结果
        poll = scripts.loadtestInterface(instance=HttpWebRequest(),
                                         data=json.dumps({
                                             "serviceName": "polling",
                                             "params": {
                                                 "sessionUuid": Pdata
                                             },
                                             "version": "1.0.0"
                                         }),
                                         desc=data['Desc'],
                                         url=data['GameUrl'],
                                         instance_pro='post')

        self.assertEqual(poll['code'], 0, poll['msg'])  # 断言
        '''--------------------------查看游戏列表----------------------'''

        # 整合数据,调用接口,获取返回结果

        gamelist = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            # data['FindGamedata']
            data=json.dumps({
                "serviceName": "findGame",
                "params": {
                    "machineId": machineId,
                    "planId": "",
                    "version": "2.0",
                    "versionInno72": "2.2"
                },
                "version": "1.0.0"
            }),
            desc=data['Desc'],
            url=data['GameUrl'],
            instance_pro='post')
        activeplanid = gamelist['data']['activityPlanId']
        print "activityPlanId:" + activeplanid
        activityPlanIdNew = unicode.encode(activeplanid)

        activityid = gamelist['data']['activityId']
        print "activityId:" + activityid
        activityIdNew = unicode.encode(activityid)

        channelid = gamelist['data']['channelId']
        print "channelId:" + channelid
        channelIdNew = unicode.encode(channelid)

        planCodeid = gamelist['data']['planCode']
        print "planCodeid:" + planCodeid
        # planCodeidNew = unicode.encode(planCodeid)

        self.assertEqual(gamelist['code'], 0, gamelist['msg'])  # 断言
        '''--------------------------查看商品信息----------------------'''
        Acdata = activityPlanIdNew
        eval(data['FindProductdata'])['params']['activityPlanId'] = Acdata

        Chdata = channelIdNew
        eval(data['FindProductdata'])['params']['channelId'] = Chdata

        # 整合数据,调用接口,获取返回结果

        product = scripts.loadtestInterface(instance=HttpWebRequest(),
                                            data=json.dumps({
                                                "serviceName": "findProduct",
                                                "params": {
                                                    "sessionUuid": Pdata,
                                                    "machineId": machineId,
                                                    "activityPlanId": Acdata,
                                                    "channelId": Chdata,
                                                    "report": "1"
                                                },
                                                "version": "1.0.0"
                                            }),
                                            desc=data['Desc'],
                                            url=data['GameUrl'],
                                            instance_pro='post')
        FgoodsId = product['data']['goods'][0]['goodsId']
        print "goodsId:" + FgoodsId
        FgoodsIdNew = unicode.encode(FgoodsId)

        goodsNumId = product['data']['goods'][0]['goodsNum']
        print "goodsNumId:" + str(goodsNumId)

        channelids = product['data']['goods'][0]['channelIds'][0]
        print 'channelids:' + channelids
        channelidsNew = unicode.encode(FgoodsId)

        self.assertEqual(product['code'], 0, product['msg'])  # 断言
        '''--------------------------下单----------------------'''

        Oactividata = activityIdNew
        eval(data['Orderdata'])['params']['activityId'] = Oactividata

        Ochdata = channelIdNew
        eval(data['Orderdata'])['params']['channelId'] = Ochdata

        Ogoods = FgoodsIdNew
        eval(data['Orderdata'])['params']['itemId'] = Ogoods
        # 整合数据,调用接口,获取返回结果

        order = scripts.loadtestInterface(instance=HttpWebRequest(),
                                          data=json.dumps({
                                              "serviceName": "order",
                                              "params": {
                                                  "sessionUuid": Pdata,
                                                  "machineId": machineId,
                                                  "activityPlanId": Acdata,
                                                  "activityId": Oactividata,
                                                  "channelId": Ochdata,
                                                  "itemId": Ogoods
                                              },
                                              "version": "1.0.0"
                                          }),
                                          desc=data['Desc'],
                                          url=data['GameUrl'],
                                          instance_pro='post')
        PorderId = order['data']['time']
        print "PorderId:" + str(PorderId)
        # PorderIdNew = unicode.encode(PorderId)

        self.assertEqual(order['code'], 0, order['msg'])  # 断言
        '''--------------------------查看订单状态----------------------'''
        # Pdata = eval(data['OrderPollingdata'])['params']['sessionUuid']
        # Pdata = SUuidtokenNew

        Orderdata = PorderId
        eval(data['Orderdata'])['params']['orderId'] = Orderdata

        # 整合数据,调用接口,获取返回结果

        orderpoll = scripts.loadtestInterface(instance=HttpWebRequest(),
                                              data=json.dumps({
                                                  "serviceName":
                                                  "orderPolling",
                                                  "params": {
                                                      "sessionUuid": Pdata,
                                                      "orderId": Orderdata
                                                  },
                                                  "version":
                                                  "1.0.0"
                                              }),
                                              desc=data['Desc'],
                                              url=data['GameUrl'],
                                              instance_pro='post')
        self.assertEqual(orderpoll['code'], 0, orderpoll['msg'])  # 断言
        '''--------------------------出货后商品减量----------------------'''
        # Pdata = eval(data['ShipmentReportdata'])['params']['sessionUuid']
        # Pdata = SUuidtokenNew

        # 整合数据,调用接口,获取返回结果

        # channelids = channelidsNew
        # eval(data['ShipmentReportdata'])['params']['channelId'] = channelids

        shipreport = scripts.loadtestInterface(
            instance=HttpWebRequest(),
            # data=data['ShipmentReportdata'],
            data=json.dumps({
                "serviceName": "shipmentReport",
                "params": {
                    "machineId": machineId,
                    "channelId": channelids,
                    "sessionUuid": Pdata,
                    "orderId": Orderdata
                },
                "version": "1.0.0"
            }),
            desc=data['Desc'],
            url=data['GameUrl'],
            instance_pro='post')
        self.assertEqual(shipreport['code'], 0, shipreport['msg'])  # 断言