*** Settings ***
Resource          flow_zmx.resource
Resource          res_zmx.resource

*** Variables ***
${path}           /api/v1/plan/update_plan

*** Test Cases ***
正例-正常修改计划
    [Tags]    F
    create session    URI    ${URL}
    ${timestamp}    Get Time    epoch
    ${plan_name}    Catenate    SEPARATOR=    接口测试    ${timestamp}
    ${content}    PUT请求结果_json    ${path}    {"name":"${plan_name}","description":"来自接口测试，并修改计划","is_active":true,"ability_id":-1,"executor_type":"client","dispatch_type":"immediate","extensions":{"useIncognito":false,"autoFocus":false,"closePage":false},"parameters":{"提示":"使用探索工具，打开百度"},"outputs_schema":[{"name":"agent_message","type":"string","description":"探索任务结束后的文字输出"}],"triggers":[{"key":"0","id":"${trigger_id1}","type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":"","end_time":"","is_active":true,"description":"","translation":"","originalData":{"id":${trigger_id1},"type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":null,"end_time":null,"is_active":true,"created_at":"${formatted_timec}","update_at":null,"next_run_time":"${formatted_timef}"},"hasChanges":false}],"id":${plan_id}}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200

反例-不传入token
    [Tags]    E
    create session    URI    ${URL}
    ${timestamp}    Get Time    epoch
    ${plan_name}    Catenate    SEPARATOR=    接口测试    ${timestamp}
    ${content}    PUT请求结果_json    ${path}    {"name":"${plan_name}","description":"来自接口测试，并修改计划","is_active":true,"ability_id":-1,"executor_type":"client","dispatch_type":"immediate","extensions":{"useIncognito":false,"autoFocus":false,"closePage":false},"parameters":{"提示":"使用探索工具，打开百度"},"outputs_schema":[{"name":"agent_message","type":"string","description":"探索任务结束后的文字输出"}],"triggers":[{"key":"0","id":"${trigger_id1}","type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":"","end_time":"","is_active":true,"description":"","translation":"","originalData":{"id":${trigger_id1},"type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":null,"end_time":null,"is_active":true,"created_at":"${formatted_timec}","update_at":null,"next_run_time":"${formatted_timef}"},"hasChanges":false}],"id":${plan_id}}    401    ${EMPTY}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-传入空白token
    [Tags]    E
    create session    URI    ${URL}
    ${timestamp}    Get Time    epoch
    ${plan_name}    Catenate    SEPARATOR=    接口测试    ${timestamp}
    ${content}    PUT请求结果_json    ${path}    {"name":"${plan_name}","description":"来自接口测试，并修改计划","is_active":true,"ability_id":-1,"executor_type":"client","dispatch_type":"immediate","extensions":{"useIncognito":false,"autoFocus":false,"closePage":false},"parameters":{"提示":"使用探索工具，打开百度"},"outputs_schema":[{"name":"agent_message","type":"string","description":"探索任务结束后的文字输出"}],"triggers":[{"key":"0","id":"${trigger_id1}","type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":"","end_time":"","is_active":true,"description":"","translation":"","originalData":{"id":${trigger_id1},"type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":null,"end_time":null,"is_active":true,"created_at":"${formatted_timec}","update_at":null,"next_run_time":"${formatted_timef}"},"hasChanges":false}],"id":${plan_id}}    401    {}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    401

反例-不传入name参数
    [Tags]    E
    create session    URI    ${URL}
    ${content}    PUT请求结果_json    ${path}    {"description":"来自接口测试，并修改计划","is_active":true,"ability_id":-1,"executor_type":"client","dispatch_type":"immediate","extensions":{"useIncognito":false,"autoFocus":false,"closePage":false},"parameters":{"提示":"使用探索工具，打开百度"},"outputs_schema":[{"name":"agent_message","type":"string","description":"探索任务结束后的文字输出"}],"triggers":[{"key":"0","id":"${trigger_id1}","type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":"","end_time":"","is_active":true,"description":"","translation":"","originalData":{"id":${trigger_id1},"type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":null,"end_time":null,"is_active":true,"created_at":"${formatted_timec}","update_at":null,"next_run_time":"${formatted_timef}"},"hasChanges":false}],"id":${plan_id}}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["type"]}    missing

反例-不传入id参数
    [Tags]    E
    create session    URI    ${URL}
    ${timestamp}    Get Time    epoch
    ${plan_name}    Catenate    SEPARATOR=    接口测试    ${timestamp}
    ${content}    PUT请求结果_json    ${path}    {"name":"${plan_name}","description":"来自接口测试，并修改计划","is_active":true,"ability_id":-1,"executor_type":"client","dispatch_type":"immediate","extensions":{"useIncognito":false,"autoFocus":false,"closePage":false},"parameters":{"提示":"使用探索工具，打开百度"},"outputs_schema":[{"name":"agent_message","type":"string","description":"探索任务结束后的文字输出"}],"triggers":[{"key":"0","id":"${trigger_id1}","type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":"","end_time":"","is_active":true,"description":"","translation":"","originalData":{"id":${trigger_id1},"type":"定时触发器","trigger_type":"date","expression":"${formatted_timef}","start_time":null,"end_time":null,"is_active":true,"created_at":"${formatted_timec}","update_at":null,"next_run_time":"${formatted_timef}"},"hasChanges":false}]}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["type"]}    missing
