*** Settings ***
Documentation    Smoke tests for plan use --execution-env-priority flag
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
Plan Use Accepts Execution Env Priority Override
    [Documentation]    Verify that ``plan use --execution-env-priority override`` works with --execution-environment
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-env-priority-override    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-env-priority-override-ok

Plan Use Accepts Execution Env Priority Fallback
    [Documentation]    Verify that ``plan use --execution-env-priority fallback`` works with --execution-environment
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-env-priority-fallback    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-env-priority-fallback-ok

Plan Use Rejects Priority Without Environment
    [Documentation]    Verify that ``plan use --execution-env-priority`` without --execution-environment fails
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-priority-no-env    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-env-priority-no-env-ok

Plan Use Defaults Priority To Fallback
    [Documentation]    Verify that --execution-environment without --execution-env-priority defaults to fallback
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-env-default-priority    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-env-default-priority-ok

Plan Use Rejects Invalid Priority Value
    [Documentation]    Verify that invalid --execution-env-priority value is rejected
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    use-invalid-priority    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    plan-env-invalid-priority-ok
