def http_get_noToken(self, url, result=1, params=None):
     from httpRequests._requests import _requests_get
     '''
     此处为判断get请求是否带有参数
     '''
     if params:
         res = _requests_get(url=url, result=result, params=params)
         return res
     else:
         res = _requests_get(url=url, result=result)
         return res
 def http_get(self, url, phone=13676561839, password=123456, result=1, params=None):
     from httpRequests._requests import _requests_get
     '''
     此处为判断get请求是否带有参数
     '''
     if params:
         headers = get_x_stream_id(phone=phone, password=password)
         res = _requests_get(url=url, headers=headers, result=result, params=params)
         return res
     else:
         headers = get_x_stream_id(phone=phone, password=password)
         res = _requests_get(url=url, headers=headers, result=result)
         return res
예제 #3
0
 def test_noXSIBalance(self):
     url = 'https://mainto-app-1-0.local.hzmantu.com/project_mainto_app/user/giftCard/balance/v1'
     logger.info('不传入x-stream-id查询余额')
     try:
         res = _requests_get(url=url, result=0)
         logger.info('不传入x-stream-id返回信息{}'.format(res))
     except:
         logger.error('传入空的x-stream-id返回True')
         raise AssertionError
 def getCityList(self):
     # 获取所有城市ID
     from httpRequests._requests import _requests_get
     get_city_url = 'https://mainto-app-1-0.local.hzmantu.com/project_mainto_app/store/getCityInBlueAndGold/v1'
     res = _requests_get(url=get_city_url, result=1)
     res = res['msg']['data']  # 获取返回的的json串中的['data']
     cityId = []
     for i in range(len(res)):
         cityId.append(res[i]['id'])
     return cityId  # 循环读取保存下来的城市id列表
 def test_NoStoreIdGetStoreInfo(self):
     url = 'https://mainto-app-1-0.local.hzmantu.com/project_mainto_app/store/getStoreInfoById/v1'
     params = {'storeId': []}
     logger.info('获取门店信息')
     logger.info('入参:{}'.format(params))
     from httpRequests._requests import _requests_get
     res = _requests_get(url=url, params=params, result=0)
     try:
         assert res['error_code'] == 422
         logger.info('pass')
     except:
         logger.error('传入空值返回正常数据{}'.format(res))
         raise AssertionError
 def test_getStoreInfoById(self):
     sid = self.getStoreId()
     url = 'https://mainto-app-1-0.local.hzmantu.com/project_mainto_app/store/getStoreInfoById/v1'
     for i in range(len(sid)):
         params = {'storeId': sid[i]}
         # 通过门店id获取门店信息判断返回的门店id是否与传入的门店id一致
         logger.info('获取门店信息')
         logger.info('入参:{}'.format(params))
         from httpRequests._requests import _requests_get
         try:
             res = _requests_get(url=url, params=params, result=1)
             assert res['msg']['id'] == sid[i]
             logger.info('Pass')
         except:
             logger.error('获取门店信息失败')
             raise AssertionError
예제 #7
0
 def test_balance(self):
     headers = self.get_id()
     url = 'https://mainto-app-1-0.local.hzmantu.com/project_mainto_app/user/giftCard/balance/v1'
     logger.info('title: 传入正确的x-stream-id')
     logger.info('传入的x-stream-id为:%s' % headers)
     try:
         res = _requests_get(url=url, result=1, headers=headers)
         logger.info('返回信息:%s' % res)
     except:
         logger.error(traceback.format_exc())
         raise AssertionError
     logger.info('')
     try:
         assert float(get_user_gift_card_balance(13676561839)) == float(res['msg'])
         logger.info('查询余额正确')
     except:
         logger.error('Api查询余额{},与数据库查询到的余额{}不一致'.format(res['msg'], get_user_gift_card_balance(13676561839)))
         logger.error(traceback.format_exc())
         raise AssertionError