42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""Helper utilities for PlanGenerationGraph Robot tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
CURRENT_DIR = Path(__file__).resolve().parent
|
|
PROJECT_ROOT = CURRENT_DIR.parent
|
|
SRC_DIR = PROJECT_ROOT / "src"
|
|
if str(SRC_DIR) not in sys.path:
|
|
sys.path.insert(0, str(SRC_DIR))
|
|
|
|
from cleveragents.agents.plan_generation import PlanGenerationGraph
|
|
from cleveragents.domain.models.core import Context
|
|
|
|
|
|
def run_context_summary() -> None:
|
|
"""Generate plan context metadata to validate Robot tests."""
|
|
|
|
graph = PlanGenerationGraph()
|
|
with tempfile.NamedTemporaryFile(delete=False, suffix=".py") as tmp:
|
|
tmp.write(b"def main():\n return True\n")
|
|
tmp_path = Path(tmp.name)
|
|
|
|
content = tmp_path.read_text()
|
|
contexts = [Context(plan_id=1, path=str(tmp_path), content=content)]
|
|
try:
|
|
result = graph._load_context({"contexts": contexts})
|
|
assert result["context_summary"], "context_summary should not be empty"
|
|
assert result["context_dependencies"], (
|
|
"context_dependencies should not be empty"
|
|
)
|
|
print("Context analysis summary ready")
|
|
finally:
|
|
tmp_path.unlink(missing_ok=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_context_summary()
|