*** Settings ***
Documentation    Smoke tests for Tool and Validation CLI commands
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_tool_cli.py

*** Test Cases ***
Tool Add Config Creates Tool
    [Documentation]    Verify that ``tool add --config`` registers a tool
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tool-add-config    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-cli-add-config-ok

Tool List Shows Tools
    [Documentation]    Verify that ``tool list`` shows registered tools
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tool-list    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-cli-list-ok

Tool Show Accepts Namespaced Name
    [Documentation]    Verify that ``tool show`` accepts a namespaced name argument
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tool-show    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-cli-show-ok

Tool Remove Accepts Namespaced Name
    [Documentation]    Verify that ``tool remove --yes`` removes a tool
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tool-remove    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-cli-remove-ok

Validation Add Config Creates Validation
    [Documentation]    Verify that ``validation add --config`` registers a validation
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validation-add-config    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-cli-add-ok

Validation Attach Links Validation To Resource
    [Documentation]    Verify that ``validation attach`` links a validation to a resource
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validation-attach    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-cli-attach-ok

Validation Detach Removes Attachment
    [Documentation]    Verify that ``validation detach --yes`` removes an attachment
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    validation-detach    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-cli-detach-ok

Tool List Type Tool Filter Works
    [Documentation]    Verify that ``tool list --type tool`` passes tool_type to service
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tool-list-type-tool    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-cli-list-type-tool-ok

Tool List Type Validation Filter Works
    [Documentation]    Verify that ``tool list --type validation`` passes tool_type to service
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    tool-list-type-validation    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-cli-list-type-validation-ok
