test(conductor_tech_lead): mock send_result not send (Phase 2.12, fixes Phase 1.1 regression)

Phase 1.1 migrated src/conductor_tech_lead.py:68 from ai_client.send() to
ai_client.send_result(). The 3 tests in TestConductorTechLead mocked
src.ai_client.send which is no longer called by the production code,
causing "send was called 0 times" failures.

Changes:
- Replace patch("src.ai_client.send") with patch("src.ai_client.send_result")
- Wrap mock return_value with Result(data=...) and mock side_effect with
  Result(data=...) values
- Add "from src.result_types import Result" import

All 9 tests in tests/test_conductor_tech_lead.py pass (3 migrated + 6
unaffected topological sort tests).
This commit is contained in:
ed
2026-06-15 16:06:17 -04:00
parent b7fd4e4f6a
commit 488254527c
+9 -8
View File
@@ -1,27 +1,28 @@
import unittest
from unittest.mock import patch
from src import conductor_tech_lead
from src.result_types import Result
import pytest
class TestConductorTechLead(unittest.TestCase):
def test_generate_tickets_retry_failure(self) -> None:
with patch('src.ai_client.send') as mock_send:
mock_send.return_value = "invalid json"
with patch('src.ai_client.send_result') as mock_send_result:
mock_send_result.return_value = Result(data="invalid json")
# 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
assert mock_send_result.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"}]']
with patch('src.ai_client.send_result') as mock_send_result:
mock_send_result.side_effect = [Result(data="invalid json"), Result(data='[{"Task": "Test"}]')]
tickets = conductor_tech_lead.generate_tickets("brief", "skeletons")
assert tickets == [{"Task": "Test"}]
assert mock_send.call_count == 2
assert mock_send_result.call_count == 2
def test_generate_tickets_success(self) -> None:
with patch('src.ai_client.send') as mock_send:
mock_send.return_value = '[{"id": "T1", "description": "desc", "depends_on": []}]'
with patch('src.ai_client.send_result') as mock_send_result:
mock_send_result.return_value = Result(data='[{"id": "T1", "description": "desc", "depends_on": []}]')
tickets = conductor_tech_lead.generate_tickets("brief", "skeletons")
self.assertEqual(len(tickets), 1)
self.assertEqual(tickets[0]['id'], "T1")