*** Settings ***
Documentation    Smoke tests for project-scoped config overrides
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Project Scoped Set And Get Roundtrip
    [Documentation]    Verify that setting a project-scoped value and reading it back works
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    set-get-roundtrip    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-project-scope-set-get-ok

Project Scoped Value Overrides Global
    [Documentation]    Verify that project-scoped value overrides the global value in resolution
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    project-overrides-global    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-project-overrides-global-ok

Project Scoped List Overrides Only
    [Documentation]    Verify that get_project_overrides returns only project-scoped keys
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    list-overrides-only    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-project-list-overrides-ok

Project Scoped CLI Set Get Roundtrip
    [Documentation]    Verify the CLI --project flag works for set and get commands
    [Tags]    tdd_issue    tdd_issue_4303

    ${result}=    Run Process    ${PYTHON}    ${HELPER}    cli-roundtrip    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-project-cli-roundtrip-ok

Non Scopable Key Rejected
    [Documentation]    Verify that a non-project-scopable key is rejected
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    non-scopable-rejected    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    config-project-non-scopable-ok
