*** Settings ***
Resource          flow_zmx.resource
Resource          res_zmx.resource
Library           get_expId.py

*** Variables ***
${path}           /api/chat/read

*** Test Cases ***
正例-正常读取消息
    [Tags]    F
    ${resp}    Get ExpId    http://bitagent.sit.ninetechone.com/${path}    ${sessionId}    ${ex_streamId}    ${token}
    log    ${resp}
    Should Contain    ${resp}[0]    EXP_
    Set Global Variable    ${expId}    ${resp}[0]

正例-正常读取对话消息
    [Tags]    F
    ${resp}    Get Message    http://bitagent.sit.ninetechone.com/${path}    ${sessionId}    ${text_streamId}    ${token}
    log    ${resp}
    Should Contain    ${resp}[0]    让我想想
    Should Contain    ${resp}[-1]    关闭

反例-传入错误的token
    [Tags]    E
    create session    URI    ${URL}
    &{header}    Create Dictionary    Authorization=test666
    ${params}    Create Dictionary    sessionId=${sessionId}    streamId=${text_streamId}
    ${resp}    Get On Session    URI    ${PATH}    params=${params}    headers=${header}    expected_status=401
    Should Be Equal As Integers    ${resp.json()["code"]}    401
    Should Be Equal As Strings    ${resp.json()["message"]}    无效的access token

反例-传入空白token
    [Tags]    E
    create session    URI    ${URL}
    &{header}    Create Dictionary    Authorization=${EMPTY}
    ${params}    Create Dictionary    sessionId=${sessionId}    streamId=${text_streamId}
    ${resp}    Get On Session    URI    ${PATH}    params=${params}    headers=${header}    expected_status=401
    Should Be Equal As Integers    ${resp.json()["code"]}    401
    Should Be Equal As Strings    ${resp.json()["message"]}    没有找到认证信息

反例-不传入sessionId参数
    [Tags]    E
    create session    URI    ${URL}
    &{header}    Create Dictionary    Authorization=${token}
    ${params}    Create Dictionary    streamId=${text_streamId}
    ${resp}    Get On Session    URI    ${PATH}    params=${params}    headers=${header}    expected_status=200
    Should Be Equal As Integers    ${resp.json()["code"]}    500
    Should Be Equal As Strings    ${resp.json()["message"]}    Server busy, please try later

反例-不传入streamId参数
    [Tags]    E
    create session    URI    ${URL}
    &{header}    Create Dictionary    Authorization=${token}
    ${params}    Create Dictionary    sessionId=${sessionId}
    ${resp}    Get On Session    URI    ${PATH}    params=${params}    headers=${header}    expected_status=200
    Should Be Equal As Integers    ${resp.json()["code"]}    500
    Should Be Equal As Strings    ${resp.json()["message"]}    Server busy, please try later
