zoukankan      html  css  js  c++  java
  • 接口测试

    get 方法用例

    url = "https://aip.douban.com/"#首页地址
    url_path =url + "v2/book/search"#子页地址
    data ={"q":"bb"}#需要传入的数据
    re = requests.get(url = url_path,params = data)#获取地址,传入数据
    json_1 =re.json()#转换json格式
    asser_Equal(re.status_code,200,"接口请求失败")

    post方法用例

    url = "https://manage-eloan-test.xinzhentech.com/modules/ecust/ecustInfo/saveOrUpdate.htm"
    
    datas = {"contacts":[{"contactuser":"深圳","contactphone":"13245937882"}]}
    
    header = {'Accept':'text/javascript, text/html, application/xml, text/xml, */*',
         'Accept-Encoding':'gzip, deflate',
         'Accept-Language':'zh-CN,zh;q=0.8',
           'Connection':'keep-alive',
          'Content-Length':'203',
          'Content-Type':'application/x-www-form-urlencoded',
          'Cookie':'JSESSIONID=6C572BAB9C882B07B2A51B162668D403; username=system',
          'Host':'manage-eloan-test.xinzhentech.com',
          'Origin':'https://manage-eloan-test.xinzhentech.com',
          'Referer':'https://manage-eloan-test.xinzhentech.com/build/index.html;
    jsessionid=D7EB59F8AFCEF0046BF6C6B962CEAD66
    ',         'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36
    (KHTML,likeGecko) Chrome/49.0.2623.110 Safari/537.36
    ',      'X-Requested-With':'XMLHttpRequest', } ret = request.post(url,data = datas ,headers = header) r_dict = ret.json() assert_Equal(r_dict["msg"],"对比结果""自定义报错提示信息") assert_Equal(r_dict[code],200,"自定义报错信息")
  • 相关阅读:
    HTTP状态码
    MySQL的order by时区分大小写
    CopyOnWriteArrayList、CopyOnWriteArraySet、ConcurrentHashMap的实现原理和适用场景
    Map接口
    Python中创建守护进程
    df说磁盘空间满了, du说没有,到底谁是对的
    几种分布式文件系统对比
    Unity:控制粒子特效的移动方向
    创建NuGet包
    NuGet的简单使用
  • 原文地址:https://www.cnblogs.com/guog1/p/8478540.html
Copyright © 2011-2022 走看看