|
12 | 12 | from azure.core.settings import settings |
13 | 13 | from gen_ai_trace_verifier import GenAiTraceVerifier |
14 | 14 | from openai import OpenAI |
15 | | -from devtools_testutils import recorded_by_proxy |
| 15 | +from devtools_testutils import recorded_by_proxy, RecordedTransport |
16 | 16 | from azure.ai.projects.models import PromptAgentDefinition, FunctionTool |
17 | 17 |
|
18 | | -from test_base import servicePreparer, recorded_by_proxy_httpx |
| 18 | +from test_base import servicePreparer |
19 | 19 | from test_ai_instrumentor_base import ( |
20 | 20 | TestAiAgentsInstrumentorBase, |
21 | 21 | CONTENT_TRACING_ENV_VARIABLE, |
@@ -188,7 +188,7 @@ def set_env_var(var_name, value): |
188 | 188 |
|
189 | 189 | @pytest.mark.usefixtures("instrument_with_content") |
190 | 190 | @servicePreparer() |
191 | | - @recorded_by_proxy_httpx |
| 191 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
192 | 192 | def test_sync_non_streaming_with_content_recording(self, **kwargs): |
193 | 193 | """Test synchronous non-streaming responses with content recording enabled.""" |
194 | 194 | self.cleanup() |
@@ -268,7 +268,7 @@ def test_sync_non_streaming_with_content_recording(self, **kwargs): |
268 | 268 |
|
269 | 269 | @pytest.mark.usefixtures("instrument_without_content") |
270 | 270 | @servicePreparer() |
271 | | - @recorded_by_proxy_httpx |
| 271 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
272 | 272 | def test_sync_non_streaming_without_content_recording(self, **kwargs): |
273 | 273 | """Test synchronous non-streaming responses with content recording disabled.""" |
274 | 274 | self.cleanup() |
@@ -348,7 +348,7 @@ def test_sync_non_streaming_without_content_recording(self, **kwargs): |
348 | 348 |
|
349 | 349 | @pytest.mark.usefixtures("instrument_with_content") |
350 | 350 | @servicePreparer() |
351 | | - @recorded_by_proxy_httpx |
| 351 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
352 | 352 | def test_sync_streaming_with_content_recording(self, **kwargs): |
353 | 353 | """Test synchronous streaming responses with content recording enabled.""" |
354 | 354 | from openai.types.responses.response_input_param import FunctionCallOutput |
@@ -438,7 +438,7 @@ def test_sync_streaming_with_content_recording(self, **kwargs): |
438 | 438 |
|
439 | 439 | @pytest.mark.usefixtures("instrument_with_content") |
440 | 440 | @servicePreparer() |
441 | | - @recorded_by_proxy_httpx |
| 441 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
442 | 442 | def test_sync_conversations_create(self, **kwargs): |
443 | 443 | """Test synchronous conversations.create() method.""" |
444 | 444 | self.cleanup() |
@@ -482,7 +482,7 @@ def test_sync_conversations_create(self, **kwargs): |
482 | 482 |
|
483 | 483 | @pytest.mark.usefixtures("instrument_with_content") |
484 | 484 | @servicePreparer() |
485 | | - @recorded_by_proxy_httpx |
| 485 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
486 | 486 | def test_sync_list_conversation_items_with_content_recording(self, **kwargs): |
487 | 487 | """Test synchronous list_conversation_items with content recording enabled.""" |
488 | 488 | self.cleanup() |
@@ -558,7 +558,7 @@ def test_sync_list_conversation_items_with_content_recording(self, **kwargs): |
558 | 558 |
|
559 | 559 | @pytest.mark.usefixtures("instrument_without_content") |
560 | 560 | @servicePreparer() |
561 | | - @recorded_by_proxy_httpx |
| 561 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
562 | 562 | def test_sync_list_conversation_items_without_content_recording(self, **kwargs): |
563 | 563 | """Test synchronous list_conversation_items with content recording disabled.""" |
564 | 564 | self.cleanup() |
@@ -670,7 +670,7 @@ def test_no_instrumentation_no_spans(self): |
670 | 670 |
|
671 | 671 | @pytest.mark.usefixtures("instrument_with_content") |
672 | 672 | @servicePreparer() |
673 | | - @recorded_by_proxy_httpx |
| 673 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
674 | 674 | def test_sync_non_streaming_without_conversation(self, **kwargs): |
675 | 675 | """Test synchronous non-streaming responses without conversation parameter.""" |
676 | 676 | self.cleanup() |
@@ -1778,7 +1778,7 @@ def test_sync_function_tool_list_conversation_items_without_content_recording(se |
1778 | 1778 |
|
1779 | 1779 | @pytest.mark.usefixtures("instrument_with_content") |
1780 | 1780 | @servicePreparer() |
1781 | | - @recorded_by_proxy_httpx |
| 1781 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
1782 | 1782 | def test_sync_multiple_text_inputs_with_content_recording_non_streaming(self, **kwargs): |
1783 | 1783 | """Test synchronous non-streaming responses with multiple text inputs and content recording enabled.""" |
1784 | 1784 | self.cleanup() |
@@ -1874,7 +1874,7 @@ def test_sync_multiple_text_inputs_with_content_recording_non_streaming(self, ** |
1874 | 1874 |
|
1875 | 1875 | @pytest.mark.usefixtures("instrument_with_content") |
1876 | 1876 | @servicePreparer() |
1877 | | - @recorded_by_proxy_httpx |
| 1877 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
1878 | 1878 | def test_sync_multiple_text_inputs_with_content_recording_streaming(self, **kwargs): |
1879 | 1879 | """Test synchronous streaming responses with multiple text inputs and content recording enabled.""" |
1880 | 1880 | self.cleanup() |
@@ -1978,7 +1978,7 @@ def test_sync_multiple_text_inputs_with_content_recording_streaming(self, **kwar |
1978 | 1978 |
|
1979 | 1979 | @pytest.mark.usefixtures("instrument_without_content") |
1980 | 1980 | @servicePreparer() |
1981 | | - @recorded_by_proxy_httpx |
| 1981 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
1982 | 1982 | def test_sync_multiple_text_inputs_without_content_recording_non_streaming(self, **kwargs): |
1983 | 1983 | """Test synchronous non-streaming responses with multiple text inputs and content recording disabled.""" |
1984 | 1984 | self.cleanup() |
@@ -2074,7 +2074,7 @@ def test_sync_multiple_text_inputs_without_content_recording_non_streaming(self, |
2074 | 2074 |
|
2075 | 2075 | @pytest.mark.usefixtures("instrument_without_content") |
2076 | 2076 | @servicePreparer() |
2077 | | - @recorded_by_proxy_httpx |
| 2077 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2078 | 2078 | def test_sync_multiple_text_inputs_without_content_recording_streaming(self, **kwargs): |
2079 | 2079 | """Test synchronous streaming responses with multiple text inputs and content recording disabled.""" |
2080 | 2080 | self.cleanup() |
@@ -2173,7 +2173,7 @@ def test_sync_multiple_text_inputs_without_content_recording_streaming(self, **k |
2173 | 2173 |
|
2174 | 2174 | @pytest.mark.usefixtures("instrument_without_content") |
2175 | 2175 | @servicePreparer() |
2176 | | - @recorded_by_proxy_httpx |
| 2176 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2177 | 2177 | def test_image_only_content_off_binary_off_non_streaming(self, **kwargs): |
2178 | 2178 | """Test image only with content recording OFF and binary data OFF (non-streaming).""" |
2179 | 2179 | self.cleanup() |
@@ -2243,7 +2243,7 @@ def test_image_only_content_off_binary_off_non_streaming(self, **kwargs): |
2243 | 2243 |
|
2244 | 2244 | @pytest.mark.usefixtures("instrument_without_content") |
2245 | 2245 | @servicePreparer() |
2246 | | - @recorded_by_proxy_httpx |
| 2246 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2247 | 2247 | def test_image_only_content_off_binary_on_non_streaming(self, **kwargs): |
2248 | 2248 | """Test image only with content recording OFF and binary data ON (non-streaming).""" |
2249 | 2249 | self.cleanup() |
@@ -2312,7 +2312,7 @@ def test_image_only_content_off_binary_on_non_streaming(self, **kwargs): |
2312 | 2312 |
|
2313 | 2313 | @pytest.mark.usefixtures("instrument_with_content") |
2314 | 2314 | @servicePreparer() |
2315 | | - @recorded_by_proxy_httpx |
| 2315 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2316 | 2316 | def test_image_only_content_on_binary_off_non_streaming(self, **kwargs): |
2317 | 2317 | """Test image only with content recording ON and binary data OFF (non-streaming).""" |
2318 | 2318 | self.cleanup() |
@@ -2381,7 +2381,7 @@ def test_image_only_content_on_binary_off_non_streaming(self, **kwargs): |
2381 | 2381 |
|
2382 | 2382 | @pytest.mark.usefixtures("instrument_with_content") |
2383 | 2383 | @servicePreparer() |
2384 | | - @recorded_by_proxy_httpx |
| 2384 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2385 | 2385 | def test_image_only_content_on_binary_on_non_streaming(self, **kwargs): |
2386 | 2386 | """Test image only with content recording ON and binary data ON (non-streaming).""" |
2387 | 2387 | self.cleanup() |
@@ -2454,7 +2454,7 @@ def test_image_only_content_on_binary_on_non_streaming(self, **kwargs): |
2454 | 2454 |
|
2455 | 2455 | @pytest.mark.usefixtures("instrument_without_content") |
2456 | 2456 | @servicePreparer() |
2457 | | - @recorded_by_proxy_httpx |
| 2457 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2458 | 2458 | def test_text_and_image_content_off_binary_off_non_streaming(self, **kwargs): |
2459 | 2459 | """Test text + image with content recording OFF and binary data OFF (non-streaming).""" |
2460 | 2460 | self.cleanup() |
@@ -2528,7 +2528,7 @@ def test_text_and_image_content_off_binary_off_non_streaming(self, **kwargs): |
2528 | 2528 |
|
2529 | 2529 | @pytest.mark.usefixtures("instrument_without_content") |
2530 | 2530 | @servicePreparer() |
2531 | | - @recorded_by_proxy_httpx |
| 2531 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2532 | 2532 | def test_text_and_image_content_off_binary_on_non_streaming(self, **kwargs): |
2533 | 2533 | """Test text + image with content recording OFF and binary data ON (non-streaming).""" |
2534 | 2534 | self.cleanup() |
@@ -2601,7 +2601,7 @@ def test_text_and_image_content_off_binary_on_non_streaming(self, **kwargs): |
2601 | 2601 |
|
2602 | 2602 | @pytest.mark.usefixtures("instrument_with_content") |
2603 | 2603 | @servicePreparer() |
2604 | | - @recorded_by_proxy_httpx |
| 2604 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2605 | 2605 | def test_text_and_image_content_on_binary_off_non_streaming(self, **kwargs): |
2606 | 2606 | """Test text + image with content recording ON and binary data OFF (non-streaming).""" |
2607 | 2607 | self.cleanup() |
@@ -2674,7 +2674,7 @@ def test_text_and_image_content_on_binary_off_non_streaming(self, **kwargs): |
2674 | 2674 |
|
2675 | 2675 | @pytest.mark.usefixtures("instrument_with_content") |
2676 | 2676 | @servicePreparer() |
2677 | | - @recorded_by_proxy_httpx |
| 2677 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2678 | 2678 | def test_text_and_image_content_on_binary_on_non_streaming(self, **kwargs): |
2679 | 2679 | """Test text + image with content recording ON and binary data ON (non-streaming).""" |
2680 | 2680 | self.cleanup() |
@@ -2751,7 +2751,7 @@ def test_text_and_image_content_on_binary_on_non_streaming(self, **kwargs): |
2751 | 2751 |
|
2752 | 2752 | @pytest.mark.usefixtures("instrument_without_content") |
2753 | 2753 | @servicePreparer() |
2754 | | - @recorded_by_proxy_httpx |
| 2754 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2755 | 2755 | def test_image_only_content_off_binary_off_streaming(self, **kwargs): |
2756 | 2756 | """Test image only with content recording OFF and binary data OFF (streaming).""" |
2757 | 2757 | self.cleanup() |
@@ -2829,7 +2829,7 @@ def test_image_only_content_off_binary_off_streaming(self, **kwargs): |
2829 | 2829 |
|
2830 | 2830 | @pytest.mark.usefixtures("instrument_without_content") |
2831 | 2831 | @servicePreparer() |
2832 | | - @recorded_by_proxy_httpx |
| 2832 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2833 | 2833 | def test_image_only_content_off_binary_on_streaming(self, **kwargs): |
2834 | 2834 | """Test image only with content recording OFF and binary data ON (streaming).""" |
2835 | 2835 | self.cleanup() |
@@ -2906,7 +2906,7 @@ def test_image_only_content_off_binary_on_streaming(self, **kwargs): |
2906 | 2906 |
|
2907 | 2907 | @pytest.mark.usefixtures("instrument_with_content") |
2908 | 2908 | @servicePreparer() |
2909 | | - @recorded_by_proxy_httpx |
| 2909 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2910 | 2910 | def test_image_only_content_on_binary_off_streaming(self, **kwargs): |
2911 | 2911 | """Test image only with content recording ON and binary data OFF (streaming).""" |
2912 | 2912 | self.cleanup() |
@@ -2983,7 +2983,7 @@ def test_image_only_content_on_binary_off_streaming(self, **kwargs): |
2983 | 2983 |
|
2984 | 2984 | @pytest.mark.usefixtures("instrument_with_content") |
2985 | 2985 | @servicePreparer() |
2986 | | - @recorded_by_proxy_httpx |
| 2986 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
2987 | 2987 | def test_image_only_content_on_binary_on_streaming(self, **kwargs): |
2988 | 2988 | """Test image only with content recording ON and binary data ON (streaming).""" |
2989 | 2989 | self.cleanup() |
@@ -3064,7 +3064,7 @@ def test_image_only_content_on_binary_on_streaming(self, **kwargs): |
3064 | 3064 |
|
3065 | 3065 | @pytest.mark.usefixtures("instrument_without_content") |
3066 | 3066 | @servicePreparer() |
3067 | | - @recorded_by_proxy_httpx |
| 3067 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3068 | 3068 | def test_text_and_image_content_off_binary_off_streaming(self, **kwargs): |
3069 | 3069 | """Test text + image with content recording OFF and binary data OFF (streaming).""" |
3070 | 3070 | self.cleanup() |
@@ -3145,7 +3145,7 @@ def test_text_and_image_content_off_binary_off_streaming(self, **kwargs): |
3145 | 3145 |
|
3146 | 3146 | @pytest.mark.usefixtures("instrument_without_content") |
3147 | 3147 | @servicePreparer() |
3148 | | - @recorded_by_proxy_httpx |
| 3148 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3149 | 3149 | def test_text_and_image_content_off_binary_on_streaming(self, **kwargs): |
3150 | 3150 | """Test text + image with content recording OFF and binary data ON (streaming).""" |
3151 | 3151 | self.cleanup() |
@@ -3226,7 +3226,7 @@ def test_text_and_image_content_off_binary_on_streaming(self, **kwargs): |
3226 | 3226 |
|
3227 | 3227 | @pytest.mark.usefixtures("instrument_with_content") |
3228 | 3228 | @servicePreparer() |
3229 | | - @recorded_by_proxy_httpx |
| 3229 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3230 | 3230 | def test_text_and_image_content_on_binary_off_streaming(self, **kwargs): |
3231 | 3231 | """Test text + image with content recording ON and binary data OFF (streaming).""" |
3232 | 3232 | self.cleanup() |
@@ -3307,7 +3307,7 @@ def test_text_and_image_content_on_binary_off_streaming(self, **kwargs): |
3307 | 3307 |
|
3308 | 3308 | @pytest.mark.usefixtures("instrument_with_content") |
3309 | 3309 | @servicePreparer() |
3310 | | - @recorded_by_proxy_httpx |
| 3310 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3311 | 3311 | def test_text_and_image_content_on_binary_on_streaming(self, **kwargs): |
3312 | 3312 | """Test text + image with content recording ON and binary data ON (streaming).""" |
3313 | 3313 | self.cleanup() |
@@ -3392,7 +3392,7 @@ def test_text_and_image_content_on_binary_on_streaming(self, **kwargs): |
3392 | 3392 |
|
3393 | 3393 | @pytest.mark.usefixtures("instrument_with_content") |
3394 | 3394 | @servicePreparer() |
3395 | | - @recorded_by_proxy_httpx |
| 3395 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3396 | 3396 | def test_responses_stream_method_with_content_recording(self, **kwargs): |
3397 | 3397 | """Test sync responses.stream() method with content recording enabled.""" |
3398 | 3398 | os.environ["AZURE_TRACING_GEN_AI_INSTRUMENT_RESPONSES_API"] = "True" |
@@ -3465,7 +3465,7 @@ def test_responses_stream_method_with_content_recording(self, **kwargs): |
3465 | 3465 |
|
3466 | 3466 | @pytest.mark.usefixtures("instrument_without_content") |
3467 | 3467 | @servicePreparer() |
3468 | | - @recorded_by_proxy_httpx |
| 3468 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3469 | 3469 | def test_responses_stream_method_without_content_recording(self, **kwargs): |
3470 | 3470 | """Test sync responses.stream() method without content recording.""" |
3471 | 3471 | os.environ["AZURE_TRACING_GEN_AI_INSTRUMENT_RESPONSES_API"] = "True" |
@@ -3538,7 +3538,7 @@ def test_responses_stream_method_without_content_recording(self, **kwargs): |
3538 | 3538 |
|
3539 | 3539 | @pytest.mark.usefixtures("instrument_with_content") |
3540 | 3540 | @servicePreparer() |
3541 | | - @recorded_by_proxy_httpx |
| 3541 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3542 | 3542 | def test_responses_stream_method_with_tools_with_content_recording(self, **kwargs): |
3543 | 3543 | """Test sync responses.stream() method with function tools and content recording enabled.""" |
3544 | 3544 | from openai.types.responses.response_input_param import FunctionCallOutput |
@@ -3685,7 +3685,7 @@ def test_responses_stream_method_with_tools_with_content_recording(self, **kwarg |
3685 | 3685 |
|
3686 | 3686 | @pytest.mark.usefixtures("instrument_without_content") |
3687 | 3687 | @servicePreparer() |
3688 | | - @recorded_by_proxy_httpx |
| 3688 | + @recorded_by_proxy(RecordedTransport.HTTPX) |
3689 | 3689 | def test_responses_stream_method_with_tools_without_content_recording(self, **kwargs): |
3690 | 3690 | """Test sync responses.stream() method with function tools without content recording.""" |
3691 | 3691 | from openai.types.responses.response_input_param import FunctionCallOutput |
|
0 commit comments