圆月山庄资源网 Design By www.vgjia.com

如下所示:

import requests
import unittest
import json
from pubulic_way.get_token import getSession
 
class testlogin(unittest.TestCase):
 
  def test_getIdentify(self):
    '''调用test_listCollectInfoByCreditId(self)响应数据中的taxid参数'''
    result = self.get_listCollectInfoByCreditId()
    json_result=json.loads(result)
    p1 = json_result["polygons"][0]["ENTERPRISETAXID"]
    data = {"lyname":"COL_WPOLYGON_3206","id":"8f34969c-ea5e-489c-94bc-37e54ad40660","taxid":p1}
    url = "http://10.17.17.31:8080/LandTaxSys/search/getLayerAlianame"
    headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
    cookies = self.get_cookies()
    r = requests.post(url,data=data,headers=headers,cookies=cookies)
    # print(p1)
    # print(r.status_code)
    # print(r.text)
    # return r.text
    checkpoint = '91320612MA1UYCL59U'
    if r.status_code == 200:
      if checkpoint in r.text:
        print('测试结果:Passed,断言成功。响应状态码:{}。响应数据【json】:{}'.format(r.status_code,r.text))
      else:
        print('测试结果:Failed,断言失败。响应状态码:{}。断言内容为:{}。响应数据【json】:{}'.format(r.status_code,checkpoint,r.text))
    else:
      print('测试结果:Failed,接口不通。响应状态码:{}。响应数据【json】:{}'.format(r.status_code,r.text))
 
  def get_listCollectInfoByCreditId(self):
    '''获取响应数据中的taxid参数'''
    url = "http://10.17.17.31:8080/LandTaxSys/dataEdit/listCollectInfoByCreditId"
    data = {"start":"1","end":"8","targetTaxId":"91320612MA1UYCL59U","nearbyTaxId":"","swjgDm":"23206","userId":"32060100033"}
    headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
    cookies = self.get_cookies()
    r = requests.post(url,data=data,headers=headers,cookies=cookies)
    return r.text
 
  def get_cookies(self):
    cookies = getSession()
    return cookies
 
 
 
 
if __name__ == '__main__':
  unittest.main()
 

以上这篇python:接口间数据传递与调用方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

标签:
python,接口,调用

圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com