码迷,mamicode.com
首页 > 其他好文 > 详细

接口测试之混合参数发送

时间:2017-05-15 16:22:31      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:ons   import   home   添加   nbsp   insert   dex   png   http   

“混合参数”指的是Post请求参数中既有普通字符串参数,又有json格式的参数。如添加房源时post的参数:

技术分享

首先我们需要登录系统才能够获取它的session,获取session后可以直接对单个接口进行测试。下面代码是测试“保存”房源接口:

#coding=utf-8
import requests
import json

data1 = {
Account:"System",
Password:"4a7d1ed414474e4033ac29ccb8653d9b"
}

s = requests.session()
s.post(url=http://10.10.134.86:8083/Login/CheckLogin,data=data1)
r=s.get(http://10.10.134.86:8083/Home/AccordionIndex)
print(r.text)

house={"XnewHouseCode":"","ErpHouseCode":"11302498","ErpHouseAddress":"318国道1881号222fsf路十弄22号楼1号房","ErpCode"
:"131798","ErpDistrictName":"318国道1881号","Room":"2","Hall":"1","Thebalcony":"1","Area":"123","SumFloor"
:"20","PlaceFloor":"1","HousekeeperNo":"","HousekeeperName":"","CustomserviceNo":"","CustomserviceName"
:"","BrokerNo":"16ACCDAE-FF34-43AA-8FC4-991B898F2FF5","BrokerName":"李鸿坤","LendType":"1","AddName":""
,"AddDate":"","EntrustMoney":0,"MonthMoney":0,"SeasonMoney":0,"HalfyearMoney":0,"YearsMoney":0,"Orientation"
:None,"RecommendType":None,"HouseTitle":None,"Description":"","DecorationStyleCode":None,"DecorationStyleName"
:None,"AreaCode":None,"BusinessAreaCode":None,"ModifyPerson":"","ModifyDate":None,"Characteristic":""
,"RoomInfo":[],"HouseImage":[],"RoomImage":[]}

data2={
KeyValue:None,
houseJson:json.dumps(house),
houseassetallocationJson:[],
roomsJson:[]      
}

r=s.post(url=http://10.10.134.86:8083/HouseModule/HouseInfo/Insert,data=data2)
print(r.text)

上面代码先将houseJson参数值进行编码,然后再Post

 

接口测试之混合参数发送

标签:ons   import   home   添加   nbsp   insert   dex   png   http   

原文地址:http://www.cnblogs.com/szmcn/p/6856822.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!