test(conductor): Add validation tests for Tech Lead JSON retry logic

This commit is contained in:
2026-03-06 12:32:53 -05:00
parent 880ef5f370
commit dc1b0d0fd1
2 changed files with 16 additions and 8 deletions

View File

@@ -12,12 +12,12 @@
- [x] Task: Conductor - User Manual Verification 'Phase 1: Implementation' (Protocol in workflow.md)
## Phase 2: Unit Testing
- [ ] Task: Write Simulation Tests for JSON Parsing
- [ ] WHERE: `tests/test_conductor_tech_lead.py`
- [ ] WHAT: Add tests `test_generate_tickets_retry_success` and `test_generate_tickets_retry_failure`.
- [ ] HOW: Mock `ai_client.send` side_effect to return invalid JSON first, then valid JSON. Assert call counts.
- [ ] SAFETY: Standard pytest mocking.
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Unit Testing' (Protocol in workflow.md)
- [x] Task: Write Simulation Tests for JSON Parsing
- [x] WHERE: `tests/test_conductor_tech_lead.py`
- [x] WHAT: Add tests `test_generate_tickets_retry_success` and `test_generate_tickets_retry_failure`.
- [x] HOW: Mock `ai_client.send` side_effect to return invalid JSON first, then valid JSON. Assert call counts.
- [x] SAFETY: Standard pytest mocking.
- [x] Task: Conductor - User Manual Verification 'Phase 2: Unit Testing' (Protocol in workflow.md)
## Phase 3: Final Validation
- [ ] Task: Full Suite Validation & Warning Cleanup

View File

@@ -4,12 +4,20 @@ from src import conductor_tech_lead
import pytest
class TestConductorTechLead(unittest.TestCase):
def test_generate_tickets_parse_error(self) -> None:
def test_generate_tickets_retry_failure(self) -> None:
with patch('src.ai_client.send') as mock_send:
mock_send.return_value = "invalid json"
# conductor_tech_lead.generate_tickets now raises RuntimeError on error
# conductor_tech_lead.generate_tickets now raises RuntimeError on error after 3 attempts
with pytest.raises(RuntimeError):
conductor_tech_lead.generate_tickets("brief", "skeletons")
assert mock_send.call_count == 3
def test_generate_tickets_retry_success(self) -> None:
with patch('src.ai_client.send') as mock_send:
mock_send.side_effect = ["invalid json", '[{"Task": "Test"}]']
tickets = conductor_tech_lead.generate_tickets("brief", "skeletons")
assert tickets == [{"Task": "Test"}]
assert mock_send.call_count == 2
def test_generate_tickets_success(self) -> None:
with patch('src.ai_client.send') as mock_send: