*** Settings ***
Documentation    Smoke tests for resource handler runtime
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Handler Protocol Conformance
    [Documentation]    Verify GitCheckoutHandler and FsDirectoryHandler satisfy ResourceHandler
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    protocol-check    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    protocol-check-ok

GitCheckout Handler Resolution
    [Documentation]    Verify GitCheckoutHandler resolves a git-checkout resource to a sandbox
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    git-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    git-resolve-ok

FsDirectory Handler Resolution
    [Documentation]    Verify FsDirectoryHandler resolves an fs-directory resource to a sandbox
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    fs-resolve    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    fs-resolve-ok

Handler Resolver Dynamic Import
    [Documentation]    Verify resolve_handler loads handlers from module:class strings
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolver-import    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    resolver-import-ok

Handler Resolver Error On Bad Reference
    [Documentation]    Verify resolve_handler raises HandlerResolutionError on bad references
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolver-error    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    resolver-error-ok
