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

robot framework接口测试之一-完整的测试用例

时间:2017-06-18 18:56:20      阅读:1532      评论:0      收藏:0      [点我收藏+]

标签:列表   add   rem   manage   val   lob   lol   店铺   用例   

*** Settings ***
Library           Collections
Library           json
Library           requests
Library           RequestsLibrary
Library           HttpLibrary.HTTP


*** Keywords ***
登录大风车
    [Arguments]    ${jpushid}    ${loginName}    ${password}
    ${dict}    create dictionary    Content-Type=application/x-www-form-urlencoded
    create session    api    http://dfc-test.sqaproxy.souche.com    ${dict}
    ${data}    create dictionary    jpushid=${jpushid}    loginName=${loginName}    password=${password}
    ${req}    Post Request    api    //rest/account/login    data=${data}
    log    ${req.status_code}    #?
    log    ${req.content}
    ${reqj}    to json    ${req.content}    #?
    log    ${reqj}
    ${reqdata}    get from dictionary    ${reqj}    data
    ${TT}    get from dictionary    ${reqdata}    token
    ${procode}    get from dictionary    ${reqdata}    provinceCode
    ${shopcode}    get from dictionary    ${reqdata}    store
    set global variable    ${jpushid}
    set global variable    ${TT}
    set global variable    ${shopcode}
    set global variable    ${procode}
    ${form}    create dictionary    Content-Type=application/x-www-form-urlencoded
    set global variable    ${form}

MoGet
    [Arguments]    ${apiurl}    ${params}==${EMPTY}
    ${formget}    create dictionary    Content-Type=application/x-www-form-urlencoded
    ${proxy}    set variable    http://127.0.0.0:8888/
    set global variable    ${formget}
    create session    api    http://lol.sqaproxy.souche.com    ${formget}
    ${resget}    get request    api    ${apiurl}    params=${params}
    should be equal as strings    ${resget.status_code}    200
    log    ${resget}
    ${resj}    to json    ${resget.content}
    log    ${resj}

MoPost
    [Arguments]    ${apiurl}    ${type}==${EMPTY}    ${pd}==data    ${params}==${EMPTY}
    [Documentation]    … …
    ${proxy}    set variable    http://127.0.0.0:8888/
    ${top}    run keyword if    "${type}"=="form"    create dictionary    Content-Type=application/x-www-form-urlencoded
    ...    ELSE    create dictionary    Content-Type=application/json
    log    abc
    create session    api    http://lol.sqaproxy.souche.com    ${top}
    ${res}    run keyword if    "${pd}" =="data"    post request    api    ${apiurl}    data=${params}
    ...    ELSE    post request    api    ${apiurl}    params=${params}
    should be equal as strings    ${res.status_code}    200
    log    ${res.status_code}
    ${resj}    to json    ${res.content}
    log    ${resj}
    #set global variable    ${type}

 

 

 

 1 *** Settings ***
 2 Library           json
 3 Library           Collections
 4 Library           requests
 5 Library           RequestsLibrary
 6 Resource          基础关键字a.robot
 7 
 8 *** Test Cases ***
 9 接受联盟
10     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498708    a12345678
11     ${data}    create dictionary    _security_token=${TT}    msgId=099e06c4b5b44cd2aaf69714c0c09ec4
12     MoPost    //manage/acceptAlly.json    form    data    ${data}
13 
14 申请联盟
15     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498708    a12345678
16     ${data}    create dictionary    shopCode=000055    memo=“您好,申请联盟”    _security_token=${TT}
17     MoPost    //manage/addAlly.json    form    data    ${data}
18 
19 拒绝联盟
20     [Setup]    登录大风车    161a3797c8346bb1fc1    15810001002    a12345678
21     ${data}    create dictionary    msgId=163b8f7ab4314e9cbab85d3790d194cc    _security_token=${TT}
22     MoPost    //manage/denyAlly.json    form    data    ${data}
23 
24 获取我的盟友列表
25     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
26     ${data}    create dictionary    page=1    pageSize=10    jpushid= 161a3797c8346bb1fc1    _security_token=${TT}
27     MoGet    //manage/getAllyList.json    params=${data}
28 
29 获取我的筛选盟友列表
30     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
31     ${data}    create dictionary    _security_token=${TT}
32     MoGet    /manage/getAllyListForSel.json    ${data}
33 
34 供工作台获取联盟角标
35     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
36     ${data}    create dictionary    _security_token=${TT}
37     MoGet    /manage/getDashboardNum.json    ${data}
38 
39 获取联盟消息列表
40     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
41     ${data}    create dictionary    page=1    pageSize=10    _security_token=${TT}
42     MoGet    /manage/getMsgList.json    ${data}
43 
44 获取联盟信息
45     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
46     ${data}    create dictionary    _security_token=${TT}
47     MoGet    /manage/getOverview.json    ${data}
48 
49 获取店铺联盟设置
50     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
51     ${data}    create dictionary    shopCode=${shopcode}    _security_token=${TT}
52     MoGet    /manage/getSetting.json    ${data}
53 
54 获取当前盟友数量
55     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
56     ${data}    create dictionary    shopCode=${shopcode}    _security_token=${TT}
57     MoGet    /manage/isAllyNumValid.json    ${data}
58 
59 搜索盟友
60     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498702    a12345678
61     ${data}    create dictionary    pageSize=5    page=1    province=${procode}    _security_token=${TT}
62     MoGet    /manage/searchAlly.json    ${data}
63 
64 解除联盟
65     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498704    a12345678
66     ${data}    create dictionary    _security_token=${TT}    shopCode=002187
67     MoPost    /manage/removeAlly.json    form    data    ${data}
68 
69 联盟设置
70     [Setup]    登录大风车    161a3797c8346bb1fc1    15868498704    a12345678
71     ${data}    create dictionary    _security_token=${TT}    linkName=4s用例一级    linkPhone=15868498705    shopDesc=哈哈哈哈
72     MoPost    /manage/setSetting.json    form    data    ${data}

 

robot framework接口测试之一-完整的测试用例

标签:列表   add   rem   manage   val   lob   lol   店铺   用例   

原文地址:http://www.cnblogs.com/chengchengla1990/p/7044802.html

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