Files
cleveragents-core/robot/helper_actor_schema.py
aditya 1f05648b2a test(actor): add Robot Framework integration tests for actor schema
Add Robot Framework smoke tests for actor schema validation:

- Valid actor tests: All 5 example YAMLs (LLM, tool, graph actors)
- Invalid name tests: Missing namespace validation
- Invalid LLM tests: Missing model field validation
- Invalid TOOL tests: Missing tools field validation
- Invalid GRAPH tests: Missing route and duplicate node IDs
- Helper script: CLI interface for schema validation from Robot

Part 9 of C1.schema implementation (Actor YAML Schema Models).
2026-02-17 13:46:04 +00:00

57 lines
1.5 KiB
Python

"""Robot Framework helper for actor YAML schema validation.
Provides a CLI-style interface for Robot to invoke schema validation
on actor YAML files. Exit code 0 = success, 1 = failure.
Usage:
python robot/helper_actor_schema.py validate <yaml_file>
python robot/helper_actor_schema.py validate-invalid <yaml_file>
"""
from __future__ import annotations
import sys
from pathlib import Path
# Ensure the src directory is on the import path.
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
sys.path.insert(0, _SRC)
from cleveragents.actor.schema import ActorConfigSchema # noqa: E402
def main() -> int:
"""Entry point called by Robot Framework ``Run Process``."""
if len(sys.argv) < 3:
print("Usage: helper_actor_schema.py <validate|validate-invalid> <file>")
return 1
command = sys.argv[1]
yaml_path = sys.argv[2]
if command == "validate":
try:
config = ActorConfigSchema.from_yaml_file(yaml_path)
print(f"actor-schema-ok: {config.name}")
return 0
except Exception as exc:
print(f"actor-schema-fail: {exc}")
return 1
if command == "validate-invalid":
try:
ActorConfigSchema.from_yaml_file(yaml_path)
print("actor-schema-unexpected-success")
return 1
except Exception as exc:
print(f"actor-schema-expected-fail: {exc}")
return 0
print(f"Unknown command: {command}")
return 1
if __name__ == "__main__":
sys.exit(main())