*** Settings ***
Documentation    Integration smoke tests for ScoredFragment and ContextFragment pipeline models
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Create ScoredFragment With Defaults
    [Documentation]    Create a ScoredFragment and verify default fields
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scored-create    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scored-create-ok

Create ScoredFragment With Breakdown
    [Documentation]    Create a ScoredFragment with full score breakdown
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scored-breakdown    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scored-breakdown-ok

ScoredFragment Equality By Identity
    [Documentation]    Verify equality based on uko_node + detail_depth
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scored-equality    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scored-equality-ok

ScoredFragment Deduplication Via Set
    [Documentation]    Verify set-based deduplication works
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scored-dedup    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scored-dedup-ok

ScoredFragment From Relevance Factory
    [Documentation]    Create ScoredFragment using from_relevance factory
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scored-from-relevance    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scored-from-relevance-ok

ScoredFragment Immutability
    [Documentation]    Verify ScoredFragment is frozen
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scored-frozen    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scored-frozen-ok

ContextFragment Strategy Source
    [Documentation]    Verify strategy_source field on ContextFragment
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    strategy-source    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    strategy-source-ok
