*** Settings ***
Documentation    Tool wrapping runtime smoke tests
Library          Process
Library          OperatingSystem

*** Test Cases ***
Wrapping Package Is Importable
    [Documentation]    Verify tool wrapping module can be imported
    ${result}=    Run Process    ${PYTHON}    -c
    ...    from cleveragents.tool.wrapping import ArgumentMapper, TransformExecutor, WrappedToolExecutor, WrappedToolNotFoundError, WrappingCycleError, WrappingDepthExceededError, TransformExecutionError; print('OK')
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    OK

Wrapping Exports In Tool Init
    [Documentation]    Verify wrapping types are exported from tool package
    ${result}=    Run Process    ${PYTHON}    -c
    ...    from cleveragents.tool import ArgumentMapper, TransformExecutor, WrappedToolExecutor; print('OK')
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    OK

ArgumentMapper Identity Mapping
    [Documentation]    Verify ArgumentMapper with None mapping passes args through
    ${result}=    Run Process    ${PYTHON}    robot/scripts/test_mapper_identity.py
    Should Be Equal As Integers    ${result.rc}    0    ${result.stderr}
    Should Contain    ${result.stdout}    OK

ArgumentMapper With Mapping
    [Documentation]    Verify ArgumentMapper translates arguments
    ${result}=    Run Process    ${PYTHON}    robot/scripts/test_mapper_configured.py
    Should Be Equal As Integers    ${result.rc}    0    ${result.stderr}
    Should Contain    ${result.stdout}    OK

TransformExecutor Runs Transform
    [Documentation]    Verify TransformExecutor executes transform code
    ${result}=    Run Process    ${PYTHON}    robot/scripts/test_transform_run.py
    Should Be Equal As Integers    ${result.rc}    0    ${result.stderr}
    Should Contain    ${result.stdout}    OK

TransformExecutor Sandbox Blocks Import
    [Documentation]    Verify TransformExecutor blocks import in sandbox
    ${result}=    Run Process    ${PYTHON}    robot/scripts/test_transform_sandbox.py
    Should Be Equal As Integers    ${result.rc}    0    ${result.stderr}
    Should Contain    ${result.stdout}    blocked=True

WrappedToolExecutor Simple Delegation
    [Documentation]    Verify WrappedToolExecutor delegates to wrapped tool
    ${result}=    Run Process    ${PYTHON}    robot/scripts/test_delegation.py
    Should Be Equal As Integers    ${result.rc}    0    ${result.stderr}
    Should Contain    ${result.stdout}    OK

WrappedToolExecutor Missing Tool Error
    [Documentation]    Verify WrappedToolExecutor raises on missing wrapped tool
    ${result}=    Run Process    ${PYTHON}    robot/scripts/test_missing_tool.py
    Should Be Equal As Integers    ${result.rc}    0    ${result.stderr}
    Should Contain    ${result.stdout}    error_raised=True
