*** Settings ***
Documentation     Smoke tests for session persistence: round-trip CRUD, message
...               append, export/import, and token-usage tracking.
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_session_persistence.py

*** Test Cases ***
Session Create Read Delete Round Trip
    [Documentation]    Verify session create -> get -> delete round-trip
    [Tags]    database    session    roundtrip
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    session-round-trip    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    session-round-trip-ok

Session Message Append And Ordering
    [Documentation]    Verify appending messages preserves order
    [Tags]    database    session    messages
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    message-append    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    message-append-ok

Session Export And Import Round Trip
    [Documentation]    Verify export/import cycle with checksum
    [Tags]    database    session    export
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    export-import    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    export-import-ok

Session Token Usage Tracking
    [Documentation]    Verify token usage accumulation
    [Tags]    database    session    tokens
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    token-usage    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    token-usage-ok
