f1d1f8ee6a
ISSUES CLOSED: #6329
69 lines
3.7 KiB
Plaintext
69 lines
3.7 KiB
Plaintext
*** Settings ***
|
|
Library Process
|
|
Library OperatingSystem
|
|
Library String
|
|
Suite Setup Set Environment Variables
|
|
Suite Teardown Clean Up Test Database
|
|
Test Tags resource_cli
|
|
|
|
*** Variables ***
|
|
${PYTHON} python
|
|
${DB_URL} sqlite:///build/test_resource_cli.db
|
|
|
|
*** Keywords ***
|
|
Set Environment Variables
|
|
Set Environment Variable CLEVERAGENTS_DATABASE_URL ${DB_URL}
|
|
Set Environment Variable CLEVERAGENTS_TESTING_USE_MOCK_AI true
|
|
${script}= Set Variable from cleveragents.infrastructure.database.models import Base; from sqlalchemy import create_engine; e \= create_engine("${DB_URL}"); Base.metadata.create_all(e)
|
|
${result}= Run Process ${PYTHON} -c ${script}
|
|
... env:PYTHONPATH=src timeout=120s on_timeout=kill
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
|
|
Clean Up Test Database
|
|
Remove File build/test_resource_cli.db
|
|
|
|
Run Resource Command
|
|
[Arguments] @{args}
|
|
${result}= Run Process ${PYTHON} -m cleveragents resource @{args}
|
|
... env:PYTHONPATH=src env:CLEVERAGENTS_DATABASE_URL=${DB_URL} env:CLEVERAGENTS_TESTING_USE_MOCK_AI=true
|
|
... timeout=120s on_timeout=kill stderr=STDOUT
|
|
Log ${result.stdout}
|
|
RETURN ${result}
|
|
|
|
*** Test Cases ***
|
|
Resource Type List Returns Output
|
|
[Documentation] Verify resource type list command runs without error
|
|
${result}= Run Process ${PYTHON} -m cleveragents resource type list
|
|
... env:PYTHONPATH=src env:CLEVERAGENTS_DATABASE_URL=${DB_URL} env:CLEVERAGENTS_TESTING_USE_MOCK_AI=true
|
|
... timeout=120s on_timeout=kill stderr=STDOUT
|
|
Log ${result.stdout}
|
|
Should Be Equal As Integers ${result.rc} 0
|
|
|
|
Resource Show Non Existent Returns Error
|
|
[Documentation] Verify resource show for non-existent resource fails gracefully
|
|
${result}= Run Process ${PYTHON} -m cleveragents resource show nonexistent
|
|
... env:PYTHONPATH=src env:CLEVERAGENTS_DATABASE_URL=${DB_URL} env:CLEVERAGENTS_TESTING_USE_MOCK_AI=true
|
|
... timeout=120s on_timeout=kill stderr=STDOUT
|
|
Log ${result.stdout}
|
|
Should Not Be Equal As Integers ${result.rc} 0
|
|
|
|
Resource Remove Guard Blocks Active DAG Edges
|
|
[Documentation] Ensure resource removal fails when DAG edges reference the resource
|
|
Create Directory build/resource-cli-parent
|
|
Create Directory build/resource-cli-child
|
|
${add_parent}= Run Resource Command add fs-directory local/guard-parent --path ${CURDIR}/../../build/resource-cli-parent
|
|
Should Be Equal As Integers ${add_parent.rc} 0
|
|
${add_child}= Run Resource Command add fs-directory local/guard-child --path ${CURDIR}/../../build/resource-cli-child
|
|
Should Be Equal As Integers ${add_child.rc} 0
|
|
${link}= Run Resource Command link-child local/guard-parent local/guard-child
|
|
Should Be Equal As Integers ${link.rc} 0
|
|
${remove_attempt}= Run Resource Command remove local/guard-parent --yes
|
|
Should Not Be Equal As Integers ${remove_attempt.rc} 0
|
|
Should Contain ${remove_attempt.stdout} edge(s) still reference it
|
|
${unlink}= Run Resource Command unlink-child local/guard-parent local/guard-child --yes
|
|
Should Be Equal As Integers ${unlink.rc} 0
|
|
${remove_child}= Run Resource Command remove local/guard-child --yes
|
|
Should Be Equal As Integers ${remove_child.rc} 0
|
|
${remove_parent}= Run Resource Command remove local/guard-parent --yes
|
|
Should Be Equal As Integers ${remove_parent.rc} 0
|