*** Settings ***
Documentation     Integration tests for project migration: NamespacedProjectModel
...               and ProjectResourceLinkModel round-trip persistence with SQLite.
Resource          ${CURDIR}/common.resource
Suite Setup       Setup Test Environment
Suite Teardown    Cleanup Test Environment

*** Variables ***
${HELPER_SCRIPT}    robot/helper_project_migration.py

*** Test Cases ***
Project Table Round Trip
    [Documentation]    Verify NamespacedProjectModel can insert and retrieve a project
    [Tags]    database    project    roundtrip
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    project-round-trip    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    project-round-trip-ok

Project Resource Link Round Trip
    [Documentation]    Verify ProjectResourceLinkModel can link a resource to a project
    [Tags]    database    project    link    roundtrip
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    link-round-trip    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    link-round-trip-ok

Project Domain Conversion
    [Documentation]    Verify NamespacedProjectModel to_domain and from_domain work
    [Tags]    database    project    domain
    ${result}=    Run Process    ${PYTHON}    ${HELPER_SCRIPT}    domain-conversion    cwd=${WORKSPACE}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    domain-conversion-ok
