test(ai_client_result): migrate to send_result(); drop test_send_deprecated (Phase 2.7)
Per plan Task 2.7: - DELETE test_send_deprecated_emits_warning (obsolete after Phase 6; send() is being removed) - RENAME test_send_extracts_data_from_result -> test_send_result_does_not_emit_deprecation (this is the regression test the plan said to KEEP; it now asserts the new API does not emit a deprecation warning, instead of testing the old behavior) - MIGRATE test_send_extracts_data_from_result (renamed to the above) - MIGRATE test_send_returns_empty_string_on_error_result -> test_send_result_returns_empty_data_with_error_on_auth_failure (asserts the Result has data="" and not ok) 5 tests pass (down from 6; the deleted test removed 1; the renamed test_send_extracts_data_from_result became test_send_result_does_not_emit_deprecation).
This commit is contained in:
@@ -13,15 +13,15 @@ def test_send_result_public_api_returns_result() -> None:
|
||||
assert r.data == "hello"
|
||||
|
||||
|
||||
def test_send_deprecated_emits_warning() -> None:
|
||||
def test_send_result_does_not_emit_deprecation() -> None:
|
||||
import warnings
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
warnings.simplefilter("always")
|
||||
with patch.object(ai_client, "set_provider"):
|
||||
with patch.object(ai_client, "_send_gemini", return_value=Result(data="hi")):
|
||||
result = ai_client.send("system", "user")
|
||||
assert result == "hi"
|
||||
assert any(issubclass(x.category, DeprecationWarning) for x in w)
|
||||
r = ai_client.send_result("system", "user")
|
||||
assert r.ok and r.data == "hi"
|
||||
assert not any(issubclass(x.category, DeprecationWarning) for x in w)
|
||||
|
||||
|
||||
def test_send_result_preserves_errors() -> None:
|
||||
@@ -33,19 +33,13 @@ def test_send_result_preserves_errors() -> None:
|
||||
assert r.errors == [err]
|
||||
|
||||
|
||||
def test_send_extracts_data_from_result() -> None:
|
||||
with patch.object(ai_client, "set_provider"):
|
||||
with patch.object(ai_client, "_send_gemini", return_value=Result(data="result text")):
|
||||
result = ai_client.send("system", "user")
|
||||
assert result == "result text"
|
||||
|
||||
|
||||
def test_send_returns_empty_string_on_error_result() -> None:
|
||||
def test_send_result_returns_empty_data_with_error_on_auth_failure() -> None:
|
||||
err = ErrorInfo(kind=ErrorKind.AUTH, message="bad key", source="test")
|
||||
with patch.object(ai_client, "set_provider"):
|
||||
with patch.object(ai_client, "_send_gemini", return_value=Result(data="", errors=[err])):
|
||||
result = ai_client.send("system", "user")
|
||||
assert result == ""
|
||||
r = ai_client.send_result("system", "user")
|
||||
assert not r.ok
|
||||
assert r.data == ""
|
||||
|
||||
|
||||
def test_classify_gemini_error_returns_error_info() -> None:
|
||||
|
||||
Reference in New Issue
Block a user