*** Settings ***
Documentation     Smoke tests for resource registry and project services
Library           Process
Library           OperatingSystem

*** Test Cases ***
Resource Registry Service Module Is Importable
    [Documentation]    Verify the resource registry service module can be imported
    ${result}=    Run Process    ${PYTHON}    -c
    ...    from cleveragents.application.services.resource_registry_service import ResourceRegistryService\nprint("OK")
    ...    env:PYTHONPATH=src
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    OK

Resource Registry Bootstrap Creates Built-in Types
    [Documentation]    Verify bootstrap registers built-in types using in-memory DB
    ${script}=    Catenate    SEPARATOR=\n
    ...    from sqlalchemy import create_engine
    ...    from sqlalchemy.orm import sessionmaker
    ...    from cleveragents.infrastructure.database.models import Base
    ...    from cleveragents.application.services.resource_registry_service import ResourceRegistryService
    ...    engine = create_engine("sqlite:///:memory:")
    ...    Base.metadata.create_all(engine)
    ...    sf = sessionmaker(bind=engine)
    ...    svc = ResourceRegistryService(session_factory=sf)
    ...    types = [t.name for t in svc.list_types()]
    ...    assert "git-checkout" in types, f"git-checkout not in {types}"
    ...    assert "fs-directory" in types, f"fs-directory not in {types}"
    ...    print("PASS")
    ${result}=    Run Process    ${PYTHON}    -c    ${script}    env:PYTHONPATH=src
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    PASS

DI Container Provides Resource Registry Service
    [Documentation]    Verify the DI container wires ResourceRegistryService
    ${script}=    Catenate    SEPARATOR=\n
    ...    from cleveragents.application.container import Container
    ...    c = Container()
    ...    svc = c.resource_registry_service()
    ...    assert type(svc).__name__ == "ResourceRegistryService"
    ...    print("PASS")
    ${result}=    Run Process    ${PYTHON}    -c    ${script}    env:PYTHONPATH=src
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    PASS
