*** Settings ***
Documentation    TDD Bug #990 — automation_profile._get_service() bypasses DI container
...              Integration smoke tests verifying that _get_service() in
...              automation_profile.py resolves AutomationProfileService through the
...              DI container rather than calling create_engine or sessionmaker directly.
...              Bug #990 was fixed by PR #1181; these tests serve as regression guards.
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

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

*** Test Cases ***
TDD Automation Profile DI Container Resolution
    [Documentation]    Verify _get_service() returns the service from the DI container
    [Tags]    tdd_bug    tdd_bug_990    tdd_issue    tdd_issue_990
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    container-resolution    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-ap990-container-resolution-ok

TDD Automation Profile DI Bypass Check
    [Documentation]    Verify _get_service() does not call create_engine or sessionmaker directly
    [Tags]    tdd_bug    tdd_bug_990    tdd_issue    tdd_issue_990
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    di-bypass    cwd=${WORKSPACE}    timeout=120s    on_timeout=kill
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    tdd-ap990-di-bypass-ok
