test(qwen): adapt 2 tests to Result API (Phase 3, fixes 2 pre-existing failures)
The _send_qwen() function returns Result[str] after the
data_oriented_error_handling_20260606 refactor (commit 64d6ba2d),
but 2 tests in test_qwen_provider.py were asserting against the
raw str type. They were 2 of the 10 pre-existing failures documented
in the track spec.
Changes (mirrors the doeh_test_thinking_cleanup_20260615 pattern for
grok/llama/llama_native):
- Replace assert result == "hi from qwen" with assert result.ok and result.data == "hi from qwen"
- Replace assert "cat" in result.lower() with assert result.ok and "cat" in result.data.lower()
- Add "from src.result_types import Result" import
All 5 tests in test_qwen_provider.py now pass (was 3/5).
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from unittest.mock import MagicMock, patch
|
||||
import pytest
|
||||
from src import ai_client
|
||||
from src.result_types import Result
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _reset_qwen_state():
|
||||
@@ -15,7 +16,7 @@ def test_send_qwen_routes_to_dashscope(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
with patch("src.ai_client._ensure_qwen_client") as ensure, \
|
||||
patch("src.ai_client._dashscope_call", return_value={"text": "hi from qwen", "tool_calls": [], "usage": {"input_tokens": 10, "output_tokens": 5}}) as call:
|
||||
result = ai_client._send_qwen("system", "user", ".", None, "", False, None, None, None)
|
||||
assert result == "hi from qwen"
|
||||
assert result.ok and result.data == "hi from qwen"
|
||||
call.assert_called_once()
|
||||
ensure.assert_called_once()
|
||||
|
||||
@@ -25,7 +26,7 @@ def test_qwen_vision_vl_model_accepts_image(monkeypatch: pytest.MonkeyPatch) ->
|
||||
patch("src.ai_client._dashscope_call", return_value={"text": "I see a cat", "tool_calls": [], "usage": {"input_tokens": 10, "output_tokens": 5}}) as call:
|
||||
file_items = [{"path": "/tmp/cat.png", "is_image": True, "base64_data": "iVBOR..."}]
|
||||
result = ai_client._send_qwen("system", "describe this image", ".", file_items, "", False, None, None, None)
|
||||
assert "cat" in result.lower()
|
||||
assert result.ok and "cat" in result.data.lower()
|
||||
kwargs = call.call_args.kwargs
|
||||
msgs_str = str(kwargs.get("messages", [])).lower()
|
||||
assert "image" in msgs_str or "cat.png" in msgs_str
|
||||
|
||||
Reference in New Issue
Block a user