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

*** Variables ***
${path}           /api/v1/mcp/create_or_update

*** Test Cases ***
正例-创建MCP服务成功
    [Tags]    F
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"name":"接口测试${secs1}","description":"来自接口的数据","url":"https://www.mcpcn.cc/mcp/LotteryQuery/9853b040-081d-47cb-8d3f-d6a42905f696","scope":["general","explore"],"auth":{"type":"none","username":"","password":"","token":""},"headers":{},"type":"streamable","created_by_name":""}    200    ${zh_token}
    Should Be Equal As Strings    ${content["code"]}    200
    Should Contain    ${content}    data
    Set Global Variable    ${MCP_id}    ${content["data"]}

正例-更新MCP服务成功
    [Tags]    F
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"id":${MCP_id},"name":"接口测试${secs1}","description":"来自接口的数据，更新测试","url":"https://www.mcpcn.cc/mcp/LotteryQuery/9853b040-081d-47cb-8d3f-d6a42905f696","scope":["general","explore"],"auth":{"type":"none","username":"","password":"","token":""},"headers":{},"type":"streamable","created_by_name":"接口测试租管"}    200    ${zh_token}
    Should Be Equal As Strings    ${content["code"]}    200
    Should Contain    ${content}    data
    Set Global Variable    ${MCP_i}    ${content["data"]}

反例-不传入token
    [Tags]    E
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"name":"接口测试${secs1}","description":"来自接口的数据","url":"https://www.mcpcn.cc/mcp/LotteryQuery/9853b040-081d-47cb-8d3f-d6a42905f696","scope":["general","explore"],"auth":{"type":"none","username":"","password":"","token":""},"headers":{},"type":"streamable","created_by_name":""}    401    ${EMPTY}
    Should Be Equal As Strings    ${content["code"]}    401

反例-传入空白token
    [Tags]    E
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"name":"接口测试${secs1}","description":"来自接口的数据","url":"https://www.mcpcn.cc/mcp/LotteryQuery/9853b040-081d-47cb-8d3f-d6a42905f696","scope":["general","explore"],"auth":{"type":"none","username":"","password":"","token":""},"headers":{},"type":"streamable","created_by_name":""}    401    {}
    Should Be Equal As Strings    ${content["code"]}    401

反例-不传入name参数
    [Tags]    E
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"description":"来自接口的数据","url":"https://www.mcpcn.cc/mcp/LotteryQuery/9853b040-081d-47cb-8d3f-d6a42905f696","scope":["general","explore"],"auth":{"type":"none","username":"","password":"","token":""},"headers":{},"type":"streamable","created_by_name":""}    422    ${zh_token}
    Should Contain    ${content}    detail

反例-不传入url参数
    [Tags]    E
    ${secs1}    Get Time    epoch
    create session    URI    ${URL}
    ${content}    POST请求结果    ${path}    {"name":"接口测试${secs1}","description":"来自接口的数据","scope":["general","explore"],"auth":{"type":"none","username":"","password":"","token":""},"headers":{},"type":"streamable","created_by_name":""}    422    ${zh_token}
    Should Contain    ${content}    detail
