*** Settings ***
Documentation    Integration tests for LangGraph Platform RemoteGraph integration.
...              Validates RemoteGraphManager lifecycle, graph registration,
...              invocation stubs, and PostgreSQL connection utilities.
...              Per ADR-048: server uses LangGraph Platform with RemoteGraph
...              for server-side actor execution.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
RemoteGraphManager Not Configured
    [Documentation]    Verify RemoteGraphManager reports unavailable when no platform URL given
    [Tags]    integration    langgraph-platform    server    remote-graph
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    manager-not-configured    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    remote-graph-manager-not-configured-ok

RemoteGraphManager Configured
    [Documentation]    Verify RemoteGraphManager is available when platform URL is given
    [Tags]    integration    langgraph-platform    server    remote-graph
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    manager-configured    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    remote-graph-manager-configured-ok

RemoteGraphManager Graph Registration
    [Documentation]    Verify graph registration and listing lifecycle
    [Tags]    integration    langgraph-platform    server    remote-graph
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    graph-registration    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    remote-graph-registration-ok

RemoteGraphManager Invoke Stub
    [Documentation]    Verify invoke raises RemoteGraphNotAvailableError for stub
    [Tags]    integration    langgraph-platform    server    remote-graph
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    invoke-stub    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    remote-graph-invoke-stub-ok

RemoteGraphManager Health Check
    [Documentation]    Verify health_check returns False for stub implementation
    [Tags]    integration    langgraph-platform    server    remote-graph
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    health-check    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    remote-graph-health-check-ok

PostgreSQL Connection Config
    [Documentation]    Verify PostgreSQLConnectionConfig validation and URL building
    [Tags]    integration    langgraph-platform    server    postgresql
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    postgresql-config    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    postgresql-config-ok

PostgreSQL URL Detection
    [Documentation]    Verify is_postgresql_url correctly identifies PostgreSQL URLs
    [Tags]    integration    langgraph-platform    server    postgresql
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    postgresql-url-detection    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    postgresql-url-detection-ok

LangGraph Platform Module Exports
    [Documentation]    Verify RemoteGraph classes are exported from langgraph package
    [Tags]    integration    langgraph-platform    server    remote-graph
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    module-exports    cwd=${WORKSPACE}    timeout=30s
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Not Contain    ${result.stdout}${result.stderr}    Traceback
    Should Contain    ${result.stdout}    module-exports-ok
