From 019297864678c73acf21209c978bfc80b82745e4 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 15 Jun 2026 16:55:30 -0400 Subject: [PATCH] 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). --- tests/test_ai_client_result.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/test_ai_client_result.py b/tests/test_ai_client_result.py index b25a10c6..170dca22 100644 --- a/tests/test_ai_client_result.py +++ b/tests/test_ai_client_result.py @@ -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: