26 lines
1.0 KiB
Python
26 lines
1.0 KiB
Python
import warnings
|
|
from unittest.mock import patch
|
|
from src import ai_client
|
|
from src.result_types import Result
|
|
|
|
|
|
def test_send_deprecated_warning_emitted_once_per_site() -> None:
|
|
with patch.object(ai_client, "set_provider"):
|
|
with patch.object(ai_client, "_send_anthropic_result", return_value=Result(data="x")):
|
|
with warnings.catch_warnings(record=True) as w:
|
|
warnings.simplefilter("always")
|
|
ai_client.send("s", "u")
|
|
ai_client.send("s", "u")
|
|
deprecation_warnings = [x for x in w if issubclass(x.category, DeprecationWarning)]
|
|
assert len(deprecation_warnings) >= 1
|
|
|
|
|
|
def test_send_result_does_not_emit_deprecation() -> None:
|
|
with patch.object(ai_client, "set_provider"):
|
|
with patch.object(ai_client, "_send_anthropic_result", return_value=Result(data="x")):
|
|
with warnings.catch_warnings(record=True) as w:
|
|
warnings.simplefilter("always")
|
|
ai_client.send_result("s", "u")
|
|
deprecation_warnings = [x for x in w if issubclass(x.category, DeprecationWarning)]
|
|
assert len(deprecation_warnings) == 0
|