test(llama_native): adapt 4 tests to Result API (doeh cleanup Phase 2.3)
This commit is contained in:
@@ -80,7 +80,7 @@ def test_send_llama_native_calls_ollama_chat_when_localhost() -> None:
|
||||
}
|
||||
with _mock_requests_with(mock_response):
|
||||
result = ai_client._send_llama_native("system", "user", ".", None, "", False, None, None, None)
|
||||
assert "hi from native ollama" in result
|
||||
assert result.ok and "hi from native ollama" in result.data
|
||||
|
||||
def test_send_llama_native_preserves_thinking_field() -> None:
|
||||
"""Ollama's 'thinking' field should be captured and rendered in the output."""
|
||||
@@ -93,8 +93,8 @@ def test_send_llama_native_preserves_thinking_field() -> None:
|
||||
}
|
||||
with _mock_requests_with(mock_response):
|
||||
result = ai_client._send_llama_native("system", "user", ".", None, "", False, None, None, None)
|
||||
assert "I thought about it" in result
|
||||
assert "answer" in result
|
||||
assert result.ok and "I thought about it" in result.data
|
||||
assert "answer" in result.data
|
||||
|
||||
def test_send_llama_routes_to_native_when_localhost() -> None:
|
||||
"""The dispatcher in _send_llama must route localhost/127.0.0.1 to _send_llama_native."""
|
||||
@@ -108,7 +108,7 @@ def test_send_llama_routes_to_native_when_localhost() -> None:
|
||||
with _mock_requests_with(mock_response), \
|
||||
patch("src.ai_client._ensure_llama_client") as ensure:
|
||||
result = ai_client._send_llama("system", "user", ".", None, "", False, None, None, None)
|
||||
assert "via native" in result
|
||||
assert result.ok and "via native" in result.data
|
||||
assert not ensure.called, "_send_llama should NOT instantiate the openai client for native backend"
|
||||
|
||||
def test_send_llama_keeps_openai_path_for_non_local() -> None:
|
||||
@@ -123,6 +123,6 @@ def test_send_llama_keeps_openai_path_for_non_local() -> None:
|
||||
with patch("src.ai_client._ensure_llama_client", return_value=mock_client) as ensure, \
|
||||
_mock_requests_with(MagicMock(json=MagicMock(return_value={}))) as warm:
|
||||
result = ai_client._send_llama("system", "user", ".", None, "", False, None, None, None)
|
||||
assert "via openrouter" in result
|
||||
assert result.ok and "via openrouter" in result.data
|
||||
assert ensure.called
|
||||
assert not warm.return_value.post.called, "non-local backend must NOT hit Ollama's /api/chat"
|
||||
|
||||
Reference in New Issue
Block a user