def test_2_del_order(self): self.headers['X-TOKEN'] = gg.get_value("token") data['orderId'] = gg.get_value('orderid') r = res.run_main(url=''.join([host, del_path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'),200,'接口请求失败') self.assertEqual(r.json().get('msg'),'成功','返回信息错误') self.logger.info('订单删除成功') except Exception as e: self.logger.error(e) self.logger.error('订单删除失败')
def test_3_del_picture(self): self.headers['X-TOKEN'] = gg.get_value("token") data = gg.get_value('pictureid') try: r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) self.assertEqual(r.json().get('code'),200,'接口请求失败') self.assertEqual(r.json().get('msg'),'删除成功!','返回信息不一致') self.logger.info('相册删除完成') except Exception as e: self.logger.error(e) self.logger.error('相册删除失败')
def test_4_buy_order(self): self.headers['X-TOKEN'] = gg.get_value("token") data[2]['orders'] = [{'orderId':'{}'.format(gg.get_value('orderid')),'couponId':'','couponCount':0}] data[2]['orders'] = json.dumps(data[0]['orders']) r = res.run_main(url=''.join([host, path]), data=data[2], method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'),503,'接口请求失败') self.assertEqual(r.json().get('msg'),'请稍后再试','返回信息错误') self.logger.info('收货地址为空,支付ID创建失败') except Exception as e: self.logger.error(e)
def test_1_buy_order(self): self.headers['X-TOKEN'] = gg.get_value("token") data[0]['addressId'] = gg.get_value('addid') data[0]['orders'] = [{'orderId':'{}'.format(gg.get_value('orderid')),'couponId':'','couponCount':0}] data[0]['orders'] = json.dumps(data[0]['orders']) r = res.run_main(url=''.join([host, path]), data=data[0], method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'),200,'接口请求失败') self.assertEqual(r.json().get('msg'),'成功','返回信息错误') self.assertNotEqual(r.json().get('data').get('mergePayId'), None, '支付ID为空') payid = r.json().get("data").get("mergePayId") gg.set_value('payid',payid) self.logger.info("支付ID创建成功,订单支付ID为:{}".format( r.json().get("data").get("mergePayId"))) except Exception as e: self.logger.info(e) self.logger.error('支付ID创建失败')
def test_3_buy_order(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data[1], method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 409, '接口请求失败') self.assertEqual(r.json().get('msg'),'订单信息错误','返回信息错误') self.logger.info('订单信息错误,支付ID创建失败') except Exception as e: self.logger.error(e)
def test_2_goodsdetail(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, info_path]), data=info_data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求失败') self.assertEqual(r.json().get('msg'), '获取成功', '返回信息错误') self.logger.info('查看商品详情成功') except Exception as e: self.logger.error(e) self.logger.error('查看商品详情失败')
def test_1_getmoney(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'),200,'接口请求失败') self.assertEqual(r.json().get('msg'),'修改成功','返回信息错误') self.logger.info('改名成功') except Exception as e: self.logger.error(e) self.logger.error('改名失败')
def test_3_add_address(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data[2], method='post', headers=self.headers) try: if r.json().get('code') != 200: self.logger.info(r.json().get('msg')) except: exit()
def test_5_getmessage(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, money_path]), data=money_data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求成功') self.assertEqual(r.json().get('msg'), '获取成功', '返回信息错误') self.logger.info('获取账户通知列表验证成功') except Exception as e: self.logger.error(e) self.logger.error('获取账户通知列表验证失败')
def test_3_bindagent(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data[1], method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 0, '接口请求失败') self.assertEqual(r.json().get('msg'), '未找到上级会员信息', '返回信息错误') self.logger.info('缺少上级ID请求断言正确') except Exception as e: self.logger.error(e) self.logger.error('绑定上级失败')
def test_1_getmoney(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'),200,'接口请求失败') self.assertEqual(r.json().get('msg'),'获取成功','返回信息错误') self.logger.info('余额兔币查询成功') self.logger.info('余额:{}'.format(r.json().get('data').get('balance'))) self.logger.info('兔币:{}个'.format(r.json().get('data').get('tuTuBiBalance'))) self.logger.info('红包:{}个'.format(r.json().get('data').get('redPacketCount'))) self.logger.info('卡券:{}个'.format(r.json().get('data').get('couponCount'))) except Exception as e: self.logger.error(e) self.logger.error('余额兔币查询失败')
def test_1_get_buyorder(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求成功') self.assertEqual(r.json().get('msg'), '成功', '返回信息错误') self.assertNotEqual(r.json().get('data'), None, '随机购买弹窗没有放数据') self.logger.info('随机弹出购买信息接口获取成功') except Exception as e: self.logger.error(e) self.logger.error('接口验证失败')
def test_1_creat_picture(self): self.headers['X-TOKEN'] = gg.get_value("token") try: r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) self.assertEqual(r.json().get('code'), 200, '接口请求失败') self.assertNotEqual(r.json().get('data').get('albumId'), None, '相册ID为空') pictureid = r.json().get('data') gg.set_value('pictureid',pictureid) self.logger.info('相册ID提取成功') self.logger.info('相册创建成功') except Exception as e: self.logger.error(e) self.logger.error('相册创建失败') exit()
def test_7_add_address(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data[0], method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求失败') self.assertEqual(r.json().get('data').get('status'), 'succ', '返回信息错误') self.logger.info('地址添加成功') except Exception as e: self.logger(e) self.logger.info('地址添加失败')
def test_1_creat_picture(self): self.headers['X-TOKEN'] = gg.get_value("token") try: r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) self.assertEqual(r.json().get('code'), 200, '接口请求失败') self.assertEqual(r.json().get('msg'), '成功', '作品获取失败') self.logger.info('作品列表获取成功') except Exception as e: self.logger.error(e) self.logger.error('作品列表获取失败') exit()
def test_1_creat_picture(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求失败') if r.json().get('data').get("money") != None: self.logger.info(r.json().get('msg')) if r.json().get('data').get("money") == None: self.logger.info('今日已签到') except Exception as e: self.logger(e) self.logger.error(r.json().get('msg'))
def test_1_getagentid(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data[0], method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求失败') self.assertEqual(r.json().get('msg'), '获取成功', '返回信息错误') self.assertNotEquals(r.json().get('data').get('userId'), None, 'ID为空') self.logger.info('获取代理ID成功') except Exception as e: self.logger.error(e) self.logger.error('获取代理ID失败')
def test_1_get_shop(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求成功') self.assertEqual(r.json().get('msg'), '成功', '返回信息错误') self.assertEqual(r.json().get('data').get('levelName'), '钻石店铺', '返回信息错误') self.logger.info('获取店铺信息成功') except Exception as e: self.logger.error(e) self.logger.error('接口验证失败')
def test_1_get_addid(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求失败') self.assertEqual(r.json().get('msg'), '获取成功', '返回信息错误') addid = r.json().get('data')[0].get('addressId') gg.set_value('addid', addid) self.logger.info('获取地址id成功:{}'.format( r.json().get('data')[0].get('addressId'))) except Exception as e: self.logger.error(e) self.logger.error('获取地址id失败')
def test_creat_orderid(self): self.headers['X-TOKEN'] = gg.get_value("token") r = res.run_main(url=''.join([host, path]), data=data, method='post', headers=self.headers) try: self.assertEqual(r.json().get('code'), 200, '接口请求失败') self.assertEqual(r.json().get('msg'), '成功', '返回信息错误') self.assertNotEquals(r.json().get('data').get('orderId'), None, '订单ID提取成功') orderid = r.json().get("data").get("orderId") gg.set_value('orderid', orderid) self.logger.info('创建产品订单ID成功') except Exception as e: self.logger.error(e) self.logger.error('创建产品订单ID失败')