fix(conductor): Apply review suggestions for track 'mma_utilization_refinement_20260226'
This commit is contained in:
@@ -20,11 +20,13 @@ def test_parser_invalid_role():
|
||||
with pytest.raises(SystemExit):
|
||||
parser.parse_args(['--role', 'tier5', 'Some prompt'])
|
||||
|
||||
def test_parser_prompt_required():
|
||||
"""Test that the prompt argument is mandatory."""
|
||||
def test_parser_prompt_optional():
|
||||
"""Test that the prompt argument is optional if role is provided (or handled in main)."""
|
||||
parser = create_parser()
|
||||
with pytest.raises(SystemExit):
|
||||
parser.parse_args(['--role', 'tier3'])
|
||||
# Prompt is now optional (nargs='?')
|
||||
args = parser.parse_args(['--role', 'tier3'])
|
||||
assert args.role == 'tier3'
|
||||
assert args.prompt is None
|
||||
|
||||
def test_parser_help():
|
||||
"""Test that the help flag works without raising errors (exits with 0)."""
|
||||
@@ -49,14 +51,13 @@ def test_get_model_for_role():
|
||||
|
||||
def test_execute_agent():
|
||||
"""
|
||||
Test that execute_agent calls subprocess.run with the correct gemini CLI arguments
|
||||
Test that execute_agent calls subprocess.run with powershell and the correct gemini CLI arguments
|
||||
including the model specified for the role.
|
||||
"""
|
||||
role = "tier3-worker"
|
||||
prompt = "Write a unit test."
|
||||
docs = ["file1.py", "docs/spec.md"]
|
||||
|
||||
expected_gemini_arg = "Use the mma-tier3-worker skill. Write a unit test. @file1.py @docs/spec.md"
|
||||
expected_model = "gemini-2.5-flash-lite"
|
||||
mock_stdout = "Mocked AI Response"
|
||||
|
||||
@@ -72,14 +73,16 @@ def test_execute_agent():
|
||||
args, kwargs = mock_run.call_args
|
||||
cmd_list = args[0]
|
||||
|
||||
assert cmd_list[0] == "gemini"
|
||||
assert cmd_list[1] == "-p"
|
||||
assert cmd_list[2] == expected_gemini_arg
|
||||
|
||||
# Verify the correct model is passed via --model flag
|
||||
assert "--model" in cmd_list
|
||||
model_idx = cmd_list.index("--model")
|
||||
assert cmd_list[model_idx + 1] == expected_model
|
||||
assert cmd_list[0] == "powershell.exe"
|
||||
assert "-Command" in cmd_list
|
||||
ps_cmd = cmd_list[cmd_list.index("-Command") + 1]
|
||||
assert "gemini" in ps_cmd
|
||||
assert f"--model {expected_model}" in ps_cmd
|
||||
|
||||
# Verify input contains the prompt and system directive
|
||||
input_text = kwargs.get("input")
|
||||
assert "STRICT SYSTEM DIRECTIVE" in input_text
|
||||
assert "TASK: Write a unit test." in input_text
|
||||
|
||||
assert kwargs.get("capture_output") is True
|
||||
assert kwargs.get("text") is True
|
||||
@@ -95,13 +98,15 @@ def test_get_dependencies(tmp_path):
|
||||
)
|
||||
filepath = tmp_path / "mock_script.py"
|
||||
filepath.write_text(content)
|
||||
dependencies = get_dependencies(filepath)
|
||||
dependencies = get_dependencies(str(filepath))
|
||||
assert dependencies == ['os', 'sys', 'file_cache', 'mcp_client']
|
||||
|
||||
|
||||
import re
|
||||
def test_execute_agent_logging(tmp_path):
|
||||
log_file = tmp_path / "mma_delegation.log"
|
||||
# mma_exec now uses logs/agents/ for individual logs and logs/mma_delegation.log for master
|
||||
# We will patch LOG_FILE to point to our temp location
|
||||
with patch("scripts.mma_exec.LOG_FILE", str(log_file)), \
|
||||
patch("subprocess.run") as mock_run:
|
||||
mock_process = MagicMock()
|
||||
@@ -114,10 +119,9 @@ def test_execute_agent_logging(tmp_path):
|
||||
assert log_file.exists()
|
||||
log_content = log_file.read_text()
|
||||
assert test_role in log_content
|
||||
assert test_prompt in log_content
|
||||
assert test_prompt in log_content # Master log should now have the summary prompt
|
||||
assert re.search(r"\d{4}-\d{2}-\d{2}", log_content)
|
||||
|
||||
|
||||
|
||||
def test_execute_agent_tier3_injection(tmp_path):
|
||||
main_content = "import dependency\n\ndef run():\n dependency.do_work()\n"
|
||||
main_file = tmp_path / "main.py"
|
||||
@@ -125,6 +129,8 @@ def test_execute_agent_tier3_injection(tmp_path):
|
||||
dep_content = "def do_work():\n pass\n\ndef other_func():\n print('hello')\n"
|
||||
dep_file = tmp_path / "dependency.py"
|
||||
dep_file.write_text(dep_content)
|
||||
|
||||
# We need to ensure generate_skeleton is mockable or working
|
||||
old_cwd = os.getcwd()
|
||||
os.chdir(tmp_path)
|
||||
try:
|
||||
@@ -135,10 +141,10 @@ def test_execute_agent_tier3_injection(tmp_path):
|
||||
mock_run.return_value = mock_process
|
||||
execute_agent('tier3-worker', 'Modify main.py', ['main.py'])
|
||||
assert mock_run.called
|
||||
cmd_list = mock_run.call_args[0][0]
|
||||
full_command = " ".join(str(arg) for arg in cmd_list)
|
||||
assert "DEPENDENCY SKELETON: dependency.py" in full_command
|
||||
assert "def do_work():" in full_command
|
||||
assert "Modify main.py" in full_command
|
||||
input_text = mock_run.call_args[1].get("input")
|
||||
assert "DEPENDENCY SKELETON: dependency.py" in input_text
|
||||
assert "def do_work():" in input_text
|
||||
assert "Modify main.py" in input_text
|
||||
finally:
|
||||
os.chdir(old_cwd)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user