test(conductor): Add validation tests for Tech Lead JSON retry logic
This commit is contained in:
@@ -12,12 +12,12 @@
|
|||||||
- [x] Task: Conductor - User Manual Verification 'Phase 1: Implementation' (Protocol in workflow.md)
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Implementation' (Protocol in workflow.md)
|
||||||
|
|
||||||
## Phase 2: Unit Testing
|
## Phase 2: Unit Testing
|
||||||
- [ ] Task: Write Simulation Tests for JSON Parsing
|
- [x] Task: Write Simulation Tests for JSON Parsing
|
||||||
- [ ] WHERE: `tests/test_conductor_tech_lead.py`
|
- [x] WHERE: `tests/test_conductor_tech_lead.py`
|
||||||
- [ ] WHAT: Add tests `test_generate_tickets_retry_success` and `test_generate_tickets_retry_failure`.
|
- [x] 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.
|
- [x] HOW: Mock `ai_client.send` side_effect to return invalid JSON first, then valid JSON. Assert call counts.
|
||||||
- [ ] SAFETY: Standard pytest mocking.
|
- [x] SAFETY: Standard pytest mocking.
|
||||||
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Unit Testing' (Protocol in workflow.md)
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Unit Testing' (Protocol in workflow.md)
|
||||||
|
|
||||||
## Phase 3: Final Validation
|
## Phase 3: Final Validation
|
||||||
- [ ] Task: Full Suite Validation & Warning Cleanup
|
- [ ] Task: Full Suite Validation & Warning Cleanup
|
||||||
|
|||||||
@@ -4,12 +4,20 @@ from src import conductor_tech_lead
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
class TestConductorTechLead(unittest.TestCase):
|
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:
|
with patch('src.ai_client.send') as mock_send:
|
||||||
mock_send.return_value = "invalid json"
|
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):
|
with pytest.raises(RuntimeError):
|
||||||
conductor_tech_lead.generate_tickets("brief", "skeletons")
|
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:
|
def test_generate_tickets_success(self) -> None:
|
||||||
with patch('src.ai_client.send') as mock_send:
|
with patch('src.ai_client.send') as mock_send:
|
||||||
|
|||||||
Reference in New Issue
Block a user