|
1 | 1 | from unittest import mock |
2 | 2 |
|
| 3 | +from sentry_sdk.integrations import DidNotEnable |
| 4 | + |
3 | 5 | try: |
4 | 6 | from unittest.mock import AsyncMock |
5 | 7 | except ImportError: |
@@ -518,9 +520,8 @@ def test_streaming_create_message_with_input_json_delta( |
518 | 520 | if send_default_pii and include_prompts: |
519 | 521 | assert span["data"][SPANDATA.AI_INPUT_MESSAGES] == messages |
520 | 522 | assert span["data"][SPANDATA.AI_RESPONSES] == [ |
521 | | - {"text": "", "type": "text"} |
522 | | - ] # we do not record InputJSONDelta because it could contain PII |
523 | | - |
| 523 | + {"text": "{'location': 'San Francisco, CA'}", "type": "text"} |
| 524 | + ] |
524 | 525 | else: |
525 | 526 | assert SPANDATA.AI_INPUT_MESSAGES not in span["data"] |
526 | 527 | assert SPANDATA.AI_RESPONSES not in span["data"] |
@@ -814,3 +815,22 @@ def test_add_ai_data_to_span_with_input_json_delta(sentry_init): |
814 | 815 | assert span.get_measurement("ai_prompt_tokens_used")["value"] == 10 |
815 | 816 | assert span.get_measurement("ai_completion_tokens_used")["value"] == 20 |
816 | 817 | assert span.get_measurement("ai_total_tokens_used")["value"] == 30 |
| 818 | + |
| 819 | + |
| 820 | +def test_unsupported_anthropic_version(sentry_init): |
| 821 | + with mock.patch( |
| 822 | + "sentry_sdk.integrations.anthropic.package_version", return_value=(0, 15, 0) |
| 823 | + ): |
| 824 | + with pytest.raises(DidNotEnable): |
| 825 | + sentry_init( |
| 826 | + integrations=[AnthropicIntegration()], |
| 827 | + traces_sample_rate=1.0, |
| 828 | + ) |
| 829 | + |
| 830 | + |
| 831 | +def test_no_version_info(sentry_init): |
| 832 | + with mock.patch( |
| 833 | + "sentry_sdk.integrations.anthropic.package_version", return_value=None |
| 834 | + ): |
| 835 | + with pytest.raises(DidNotEnable): |
| 836 | + sentry_init(integrations=[AnthropicIntegration()]) |
0 commit comments