44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
import subprocess
|
|
import pytest
|
|
import os
|
|
|
|
def run_ps_script(role, prompt):
|
|
"""Helper to run the run_subagent.ps1 script."""
|
|
# Using -File is safer and handles arguments better
|
|
cmd = [
|
|
"powershell", "-NoProfile", "-ExecutionPolicy", "Bypass",
|
|
"-File", "./scripts/run_subagent.ps1",
|
|
"-Role", role,
|
|
"-Prompt", prompt
|
|
]
|
|
result = subprocess.run(cmd, capture_output=True, text=True)
|
|
return result
|
|
|
|
def test_subagent_script_qa_live():
|
|
"""Verify that the QA role works and returns a compressed fix."""
|
|
prompt = "Traceback (most recent call last): File 'test.py', line 1, in <module> 1/0 ZeroDivisionError: division by zero"
|
|
result = run_ps_script("QA", prompt)
|
|
|
|
assert result.returncode == 0
|
|
# Expected output should mention the fix for division by zero
|
|
assert "zero" in result.stdout.lower()
|
|
# It should be short (QA agents compress)
|
|
assert len(result.stdout.split()) < 40
|
|
|
|
def test_subagent_script_worker_live():
|
|
"""Verify that the Worker role works and returns code."""
|
|
prompt = "Write a python function that returns 'hello world'"
|
|
result = run_ps_script("Worker", prompt)
|
|
|
|
assert result.returncode == 0
|
|
assert "def" in result.stdout.lower()
|
|
assert "hello" in result.stdout.lower()
|
|
|
|
def test_subagent_script_utility_live():
|
|
"""Verify that the Utility role works."""
|
|
prompt = "Tell me 'True' if 1+1=2, otherwise 'False'"
|
|
result = run_ps_script("Utility", prompt)
|
|
|
|
assert result.returncode == 0
|
|
assert "true" in result.stdout.lower()
|