python:接⼝间数据传递与调⽤⽅法
如下所⽰:python新手代码userid
import requests
import unittest
import json
from _token import getSession
class testlogin(unittest.TestCase):
def test_getIdentify(self):
'''调⽤test_listCollectInfoByCreditId(self)响应数据中的taxid参数'''
result = _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 = "10.17.17.31:8080/LandTaxSys/search/getLayerAlianame"
headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
cookies = _cookies()
r = requests.post(url,data=data,headers=headers,cookies=cookies)
# print(p1)
# print(r.status_code)
# )
#
checkpoint = '91320612MA1UYCL59U'
if r.status_code == 200:
if checkpoint :
print('测试结果:Passed,断⾔成功。响应状态码:{}。响应数据【json】:{}'.format(r.status_))
else:
print('测试结果:Failed,断⾔失败。响应状态码:{}。断⾔内容为:{}。响应数据【json】:{}'.format(r.status_code,))
else:
print('测试结果:Failed,接⼝不通。响应状态码:{}。响应数据【json】:{}'.format(r.status_))
def get_listCollectInfoByCreditId(self):
'''获取响应数据中的taxid参数'''
url = "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 = _cookies()
r = requests.post(url,data=data,headers=headers,cookies=cookies)
def get_cookies(self):
cookies = getSession()
return cookies
if __name__ == '__main__':
unittest.main()
以上这篇python:接⼝间数据传递与调⽤⽅法就是⼩编分享给⼤家的全部内容了,希望能给⼤家⼀个参考,也希望⼤家多多⽀持。
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论