test(mock): add standalone test for mock_gemini_cli routing
4 tests verify: epic prompt -> Track JSON, sprint prompt -> Ticket JSON with correct field names, worker prompt -> plain text, tool-result -> plain text. All pass in 0.57s. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
20
scripts/tasks/task_1_3_mock_test.toml
Normal file
20
scripts/tasks/task_1_3_mock_test.toml
Normal file
@@ -0,0 +1,20 @@
|
||||
role = "tier3-worker"
|
||||
docs = ["conductor/workflow.md", "tests/mock_gemini_cli.py"]
|
||||
prompt = """
|
||||
Create tests/test_mock_gemini_cli.py — a standalone pytest test file that invokes tests/mock_gemini_cli.py via subprocess.run() and verifies its routing logic.
|
||||
|
||||
TEST CASES (4 functions):
|
||||
1. test_epic_prompt_returns_track_json — send a prompt containing 'PATH: Epic Initialization' via stdin. Assert: stdout contains valid JSON list, each item has 'id' and 'title', no 'function_call' substring anywhere in stdout.
|
||||
2. test_sprint_prompt_returns_ticket_json — send 'Please generate the implementation tickets for this track.' via stdin. Assert: stdout contains valid JSON list, each item has 'id', 'description', 'status', 'assigned_to'. No 'function_call' in stdout.
|
||||
3. test_worker_prompt_returns_plain_text — send 'You are assigned to Ticket T1.\nTask Description: do something' via stdin. Assert: stdout is non-empty, no 'function_call' in stdout.
|
||||
4. test_tool_result_prompt_returns_plain_text — send a prompt containing the substring 'role": "tool' via stdin. Assert: returncode == 0 and stdout is non-empty.
|
||||
|
||||
IMPLEMENTATION DETAILS:
|
||||
- Use subprocess.run(['uv', 'run', 'python', 'tests/mock_gemini_cli.py'], input=prompt, capture_output=True, text=True, cwd='.')
|
||||
- Helper function get_message_content(stdout): split stdout by newlines, parse each line as JSON, find the dict with type=='message', return its 'content' field. Return '' if not found.
|
||||
- For JSON assertion tests: call get_message_content, then json.loads() the content, assert isinstance(result, list), assert len(result) > 0.
|
||||
- Each test asserts returncode == 0.
|
||||
- Imports: import subprocess, json, pytest
|
||||
- Use exactly 1-space indentation for Python code.
|
||||
- Create the file tests/test_mock_gemini_cli.py.
|
||||
"""
|
||||
Reference in New Issue
Block a user