*** Settings ***
Resource          flow_zmx.resource
Resource          res_zmx.resource
Library           String

*** Variables ***
${path}           /api/ability

*** Test Cases ***
正例-保存能力
    [Tags]    F
    ${random_string}    Generate Random String    12    [LOWER]
    log    ${random_string}
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"exploreSessionId":"${expId}","filteredStepIndices":[0],"draft":{"name":"${random_string}","description":"自动化测试能力","startPageUrl":"https://www.baidu.com","parameters":[{"name":"search_query","description":"用户希望在百度上搜索的关键词。","example": "天气预报","type": "string"}],"stepIndices": [0]}}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200
    Should Be Equal As Strings    ${content["message"]}    成功
    Set Global Variable    ${bid}    ${content["data"]}

反例-不传入token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"exploreSessionId":"EXP_ccf7bd255c8a47248b87bf73e5fd5680","filteredStepIndices":[0],"draft":{"name":"outhagent","description":"该能力用于访问百度主页，以查看其内容和功能。用户可以通过此能力快速打开百度主页，进行信息搜索和浏览。","startPageUrl":"https://www.baidu.com","parameters":[{"name":"search_query","description":"用户希望在百度上搜索的关键词。","example": "天气预报","type": "string"}],"stepIndices": [0]}}    401    {}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401
    Should Be Equal As Strings    ${content["message"]}    无效的access token

反例-传入错误参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"workerId":"a68ad587830d41aebf418a919006353e"}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    500
    Should Be Equal As Strings    ${content["message"]}    Server busy, please try later

反例-传入空参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    500
    Should Be Equal As Strings    ${content["message"]}    Server busy, please try later

反例-能力名已存在
    [Tags]    F
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"exploreSessionId":"${expId}","filteredStepIndices":[0],"draft":{"name":"outhagent","description":"该能力用于访问百度主页，以查看其内容和功能。用户可以通过此能力快速打开百度主页，进行信息搜索和浏览。","startPageUrl":"https://www.baidu.com","parameters":[{"name":"search_query","description":"用户希望在百度上搜索的关键词。","example": "天气预报","type": "string"}],"stepIndices": [0]}}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    BAE0008
    Should Be Equal As Strings    ${content["message"]}    此能力名已存在
