*** Settings ***
Documentation    Smoke tests for ACMS Scoped Backend View filtering
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
ResourceScope Creation And Containment
    [Documentation]    Verify ResourceScope creation, containment checks, and temporal default
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resource-scope    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-resource-scope-ok

ResourceScope Path Filtering
    [Documentation]    Verify include/exclude path glob matching with recursive patterns
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    path-filtering    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-path-filtering-ok

ScopedBackendView Fragment Filtering
    [Documentation]    Verify fragment visibility filtering by project and resource
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    fragment-filtering    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-fragment-filtering-ok

ScopedBackendView Backend Proxying
    [Documentation]    Verify text/vector/graph search proxying with scope injection
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    backend-proxying    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-backend-proxying-ok

ScopedBackendSet Integration
    [Documentation]    Verify ScopedBackendSet wraps multiple backends with scope enforcement
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    backend-set    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-backend-set-ok

Scope Validation Guards
    [Documentation]    Verify validate_project_scope and validate_resource_scope raise correctly
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    scope-validation    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-scope-validation-ok

ResourceAliasResolver
    [Documentation]    Verify alias resolution, resolve_many, and uniqueness validation
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    alias-resolver    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-alias-resolver-ok

Resolve Resource Scope With Filters
    [Documentation]    Verify resolve_resource_scope with include/exclude allowlist/denylist
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    resolve-scope    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    scoped-view-resolve-scope-ok
