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

*** Variables ***
${path}           /api/file-ref/download
${uploadpath}     /api/file-ref/upload
${jpg_file}       testpicture.jpg

*** Test Cases ***
正例-正常上传jpg并下载文件
    [Tags]    F
    create session    URI    ${URL}
    ${file}    Evaluate    (r'${jpg_file}', open(r'${CURDIR}${/}testfiles${/}${jpg_file}', 'rb'))
    ${data}    Create Dictionary    sessionId=${sessionId}
    ${header}    Create Dictionary    Authorization=${token}
    ${files}    Create Dictionary    file=${file}
    ${resp}    Post On Session    URI    ${uploadpath}    files=${files}    data=${data}    headers=${header}
    ${content}    Set Variable    ${resp.json()}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200
    Set Global Variable    ${jpg_streamId}    ${content["data"]["id"]}
    ${content}    GET请求结果    ${path}    {"id":"${jpg_streamId}"}    200    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200

反例-传入无效的token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    GET请求结果    ${path}    {"id":"${jpg_streamId}"}    200    {}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200

反例-不传入workerId
    [Tags]    E
    create session    URI    ${URL}
    ${content}    GET请求结果    ${path}    {}    422    ${token}
    log    ${content}
    Should Be Equal As Strings    ${content["detail"][0]["msg"]}    Field required

反例-传入空白token
    [Tags]    E
    create session    URI    ${URL}
    ${content}    GET请求结果    ${path}    {"id":"${jpg_streamId}"}    200    ${EMPTY}
    log    ${content}
    Should Be Equal As Strings    ${content["code"]}    200
