test(symbol_parsing): mock send_result not send (Phase 4, fixes 2 pre-existing failures)
The 2 tests in test_symbol_parsing.py mock src.ai_client.send but
production now uses send_result (migrated by doeh_test_thinking_cleanup_20260615
commit 24ba2499). Mocks receive 0 calls; tests fail with
"send was called 0 times".
Changes:
- Replace patch(src.ai_client.send) with patch(src.ai_client.send_result)
- Rename mock_send to mock_send_result
- Set return_value=Result(data="mocked response")
- Add "from src.result_types import Result" import
All 2 tests in test_symbol_parsing.py pass (were 2 pre-existing failures).
This commit is contained in:
@@ -4,6 +4,7 @@ from pathlib import Path
|
||||
from src.app_controller import AppController
|
||||
from src.events import UserRequestEvent
|
||||
from src import events
|
||||
from src.result_types import Result
|
||||
|
||||
@pytest.fixture
|
||||
def controller():
|
||||
@@ -42,19 +43,19 @@ def test_handle_request_event_appends_definitions(controller):
|
||||
with (
|
||||
patch('src.app_controller.parse_symbols', return_value=["Track"]) as mock_parse,
|
||||
patch('src.app_controller.get_symbol_definition', return_value=("src/models.py", "class Track: pass", 42)) as mock_get_def,
|
||||
patch('src.ai_client.send') as mock_send
|
||||
patch('src.ai_client.send_result', return_value=Result(data="mocked response")) as mock_send_result
|
||||
):
|
||||
# Execute
|
||||
controller._handle_request_event(event)
|
||||
|
||||
|
||||
# Verify
|
||||
mock_parse.assert_called_once_with("Explain @Track object")
|
||||
mock_get_def.assert_called_once()
|
||||
|
||||
|
||||
# Check if enriched prompt was sent to AI
|
||||
expected_suffix = "\n\n[Definition: Track from src/models.py (line 42)]\n```python\nclass Track: pass\n```"
|
||||
mock_send.assert_called_once()
|
||||
args, kwargs = mock_send.call_args
|
||||
mock_send_result.assert_called_once()
|
||||
args, kwargs = mock_send_result.call_args
|
||||
sent_prompt = args[1]
|
||||
assert sent_prompt == "Explain @Track object" + expected_suffix
|
||||
|
||||
@@ -68,16 +69,16 @@ def test_handle_request_event_no_symbols(controller):
|
||||
disc_text="disc_text",
|
||||
base_dir="."
|
||||
)
|
||||
|
||||
|
||||
with (
|
||||
patch('src.app_controller.parse_symbols', return_value=[]) as mock_parse,
|
||||
patch('src.ai_client.send') as mock_send
|
||||
patch('src.ai_client.send_result', return_value=Result(data="mocked response")) as mock_send_result
|
||||
):
|
||||
# Execute
|
||||
controller._handle_request_event(event)
|
||||
|
||||
|
||||
# Verify
|
||||
mock_send.assert_called_once()
|
||||
args, kwargs = mock_send.call_args
|
||||
mock_send_result.assert_called_once()
|
||||
args, kwargs = mock_send_result.call_args
|
||||
sent_prompt = args[1]
|
||||
assert sent_prompt == "Just a normal prompt"
|
||||
|
||||
Reference in New Issue
Block a user