*** Settings ***
Documentation    Smoke tests for Tool Registry persistence layer
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Register And Retrieve A Tool
    [Documentation]    Register a builtin tool and retrieve it by name
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    register-and-get    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-registry-ok

List Tools With Namespace Filter
    [Documentation]    Register tools and list with namespace filter
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-filter    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tool-list-ok

Attach And Detach Validation
    [Documentation]    Attach a validation to a resource and detach it
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    attach-detach    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    attach-detach-ok

Reject Duplicate Tool Name
    [Documentation]    Verify duplicate tool names are rejected
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    duplicate-reject    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    duplicate-reject-ok
