forked from HAL9000/cleveragents-core
fix(integration): harden actor CLI registry helpers
Ensure the actor CLI robot helpers capture rich console output explicitly so tests no longer misinterpret shared stdout, and remove obsolete TDD expected-fail tags now that the behaviour is verified. Raise FileNotFoundError when actor configs are missing so the configuration robot suite sees the expected error type. ISSUES CLOSED: #5284
This commit is contained in:
@@ -10,7 +10,7 @@ ${HELPER} ${CURDIR}/helper_actor_add_rich_output.py
|
||||
*** Test Cases ***
|
||||
Actor Add Rich Output Contains Type Field
|
||||
[Documentation] Verify that ``actor add`` rich output includes the Type field
|
||||
[Tags] tdd_issue tdd_issue_4200 tdd_expected_fail
|
||||
[Tags] tdd_issue tdd_issue_4200
|
||||
${result}= Run Process ${PYTHON} ${HELPER} add-type-field cwd=${WORKSPACE}
|
||||
Log ${result.stdout}
|
||||
Log ${result.stderr}
|
||||
@@ -19,7 +19,7 @@ Actor Add Rich Output Contains Type Field
|
||||
|
||||
Actor Add Rich Output Contains Config Panel
|
||||
[Documentation] Verify that ``actor add`` rich output includes the Config panel
|
||||
[Tags] tdd_issue tdd_issue_4200 tdd_expected_fail
|
||||
[Tags] tdd_issue tdd_issue_4200
|
||||
${result}= Run Process ${PYTHON} ${HELPER} add-config-panel cwd=${WORKSPACE}
|
||||
Log ${result.stdout}
|
||||
Log ${result.stderr}
|
||||
@@ -28,7 +28,7 @@ Actor Add Rich Output Contains Config Panel
|
||||
|
||||
Actor Add Rich Output Contains Capabilities Panel
|
||||
[Documentation] Verify that ``actor add`` rich output includes the Capabilities panel
|
||||
[Tags] tdd_issue tdd_issue_4200 tdd_expected_fail
|
||||
[Tags] tdd_issue tdd_issue_4200
|
||||
${result}= Run Process ${PYTHON} ${HELPER} add-capabilities-panel cwd=${WORKSPACE}
|
||||
Log ${result.stdout}
|
||||
Log ${result.stderr}
|
||||
@@ -37,7 +37,7 @@ Actor Add Rich Output Contains Capabilities Panel
|
||||
|
||||
Actor Add Rich Output Contains Tools Panel
|
||||
[Documentation] Verify that ``actor add`` rich output includes the Tools panel
|
||||
[Tags] tdd_issue tdd_issue_4200 tdd_expected_fail
|
||||
[Tags] tdd_issue tdd_issue_4200
|
||||
${result}= Run Process ${PYTHON} ${HELPER} add-tools-panel cwd=${WORKSPACE}
|
||||
Log ${result.stdout}
|
||||
Log ${result.stderr}
|
||||
@@ -46,7 +46,7 @@ Actor Add Rich Output Contains Tools Panel
|
||||
|
||||
Actor Add Rich Output Contains Success Line
|
||||
[Documentation] Verify that ``actor add`` rich output ends with the success status line
|
||||
[Tags] tdd_issue tdd_issue_4200 tdd_expected_fail
|
||||
[Tags] tdd_issue tdd_issue_4200
|
||||
${result}= Run Process ${PYTHON} ${HELPER} add-success-line cwd=${WORKSPACE}
|
||||
Log ${result.stdout}
|
||||
Log ${result.stderr}
|
||||
|
||||
@@ -42,7 +42,7 @@ V2 Actor Config Produces Provider And Graph Descriptor
|
||||
Should Be Equal As Numbers ${payload['options']['temperature']} 0.5
|
||||
|
||||
Missing Config File Exits With Non-Zero Code And Stderr Message
|
||||
[Tags] tdd_issue tdd_issue_4202 tdd_expected_fail
|
||||
[Tags] tdd_issue tdd_issue_4202
|
||||
${missing}= Set Variable ${OUTPUT DIR}/does_not_exist_actor.yaml
|
||||
${result}= Run Process ${PYTHON} robot/helper_actor_config.py ${missing}
|
||||
Should Not Be Equal As Integers ${result.rc} 0
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -9,9 +10,11 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from rich.console import Console
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from cleveragents.cli.commands.actor import app as actor_app
|
||||
from cleveragents.core.exceptions import NotFoundError
|
||||
from cleveragents.domain.models.core.actor import Actor
|
||||
|
||||
|
||||
@@ -55,10 +58,19 @@ def _run_actor_add(
|
||||
config_path = Path(handle.name)
|
||||
|
||||
try:
|
||||
with patch("cleveragents.cli.commands.actor._get_services") as mock_svc:
|
||||
output_buffer = io.StringIO()
|
||||
fake_console = Console(file=output_buffer, force_terminal=False, width=120)
|
||||
|
||||
with (
|
||||
patch("cleveragents.cli.commands.actor._get_services") as mock_svc,
|
||||
patch(
|
||||
"cleveragents.cli.commands.actor.console",
|
||||
fake_console,
|
||||
),
|
||||
):
|
||||
registry = MagicMock()
|
||||
# The add command uses registry.add() (YAML-first path)
|
||||
registry.add.return_value = actor
|
||||
registry.get_actor.side_effect = NotFoundError("actor not found")
|
||||
registry.upsert_actor.return_value = actor
|
||||
mock_svc.return_value = (MagicMock(), registry)
|
||||
actor_name = config_data.get("name", "local/robot-add-actor")
|
||||
result = runner.invoke(
|
||||
@@ -71,7 +83,7 @@ def _run_actor_add(
|
||||
assert result.exit_code == 0, (
|
||||
f"actor add failed (exit_code={result.exit_code}):\n{result.output}"
|
||||
)
|
||||
return result.output
|
||||
return output_buffer.getvalue()
|
||||
|
||||
|
||||
def test_add_type_field() -> None:
|
||||
|
||||
@@ -7,6 +7,7 @@ in the database while all CLI flags (--set-default, --option) are honoured.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import io
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -14,6 +15,7 @@ from pathlib import Path
|
||||
from typing import Any
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from rich.console import Console
|
||||
from typer.testing import CliRunner
|
||||
|
||||
from cleveragents.cli.commands.actor import app as actor_app
|
||||
@@ -59,7 +61,15 @@ def test_yaml_text_preserved() -> None:
|
||||
config_path = Path(handle.name)
|
||||
|
||||
try:
|
||||
with patch("cleveragents.cli.commands.actor._get_services") as mock_svc:
|
||||
fake_console = Console(file=io.StringIO(), force_terminal=False, width=120)
|
||||
|
||||
with (
|
||||
patch("cleveragents.cli.commands.actor._get_services") as mock_svc,
|
||||
patch(
|
||||
"cleveragents.cli.commands.actor.console",
|
||||
fake_console,
|
||||
),
|
||||
):
|
||||
registry = MagicMock()
|
||||
mock_actor = _make_actor(yaml_text=yaml_content)
|
||||
registry.upsert_actor.return_value = mock_actor
|
||||
@@ -100,7 +110,15 @@ def test_set_default_flag() -> None:
|
||||
config_path = Path(handle.name)
|
||||
|
||||
try:
|
||||
with patch("cleveragents.cli.commands.actor._get_services") as mock_svc:
|
||||
fake_console = Console(file=io.StringIO(), force_terminal=False, width=120)
|
||||
|
||||
with (
|
||||
patch("cleveragents.cli.commands.actor._get_services") as mock_svc,
|
||||
patch(
|
||||
"cleveragents.cli.commands.actor.console",
|
||||
fake_console,
|
||||
),
|
||||
):
|
||||
registry = MagicMock()
|
||||
registry.upsert_actor.return_value = _make_actor(yaml_text=yaml_content)
|
||||
registry.get_actor.side_effect = NotFoundError("not found")
|
||||
@@ -143,7 +161,15 @@ def test_option_override_flag() -> None:
|
||||
config_path = Path(handle.name)
|
||||
|
||||
try:
|
||||
with patch("cleveragents.cli.commands.actor._get_services") as mock_svc:
|
||||
fake_console = Console(file=io.StringIO(), force_terminal=False, width=120)
|
||||
|
||||
with (
|
||||
patch("cleveragents.cli.commands.actor._get_services") as mock_svc,
|
||||
patch(
|
||||
"cleveragents.cli.commands.actor.console",
|
||||
fake_console,
|
||||
),
|
||||
):
|
||||
registry = MagicMock()
|
||||
registry.upsert_actor.return_value = _make_actor(yaml_text=yaml_content)
|
||||
registry.get_actor.side_effect = NotFoundError("not found")
|
||||
|
||||
@@ -60,7 +60,7 @@ class ActorConfiguration(BaseModel):
|
||||
|
||||
path = config_path.expanduser()
|
||||
if not path.exists():
|
||||
raise ValueError(f"Config file not found: {path}")
|
||||
raise FileNotFoundError(f"Config file not found: {path}")
|
||||
|
||||
text = path.read_text()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user